使用Backstretch为各个页面的不同图像 [英] Using Backstretch for different images for individual pages

查看:124
本文介绍了使用Backstretch为各个页面的不同图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以提供帮助。我正在尝试使用jQuery Backstretch为Bootstrap / Wordpress中的每个特定页面应用不同的背景图像。例如:

I hope there's someone out there that can help. I am trying to use jQuery Backstretch to apply a different background image for each specific page within Bootstrap/Wordpress. e.g:

首页 - bg图片a
关于 - bg图片b
新闻 - bg图片c
等等......

Home - bg image a About - bg image b News - bg image c and so on...

我设法使用标准的Backstretch脚本为所有页面显示单个图像,但我完全迷失了(甚至在搜索之后)关于如何应用以上。

I've managed to use the standard Backstretch script to display a single image for all pages, but I am totally lost (even after searching) on how to apply the the above.

到目前为止我的代码:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://myurl.co.uk/wp-content/themes/wpbootstra/bootstrap/js/jquery.backstretch.min.js"></script>

<script>
    $.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg.jpeg");
</script>

我在footer.php中使用了这个。

I have used this in my footer.php.

有没有人有解决方案?

推荐答案

你可以试试:

<?php
if(is_page(42))
{
    echo '<script>$.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg.jpeg");</script>';
} 
else if(is_page(41))
{
    echo '<script>$.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg_b.jpeg");</script>';
}
?>

数字42,41是页面的ID。 Sp text_bg_b.jpeg将仅显示在关于我们页面上(假设其ID为41)。

The number 42, 41 being the id of the page. Sp text_bg_b.jpeg will only display on the About us page (assuming its id is 41).

这篇关于使用Backstretch为各个页面的不同图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆