0
我正在使用WooCommerce 2.1.3自定义主题。自定义主题从页面抓取'精选图像',并用它来展开和显示标题图像(一些jQuery的东西)。要点是,WooCommerce使用“产品图片”而不是“特色图片”。我假设这就是为什么我的主题没有选择照片并将其用于标题图像....标题保持空白。无论如何,将这个“特色图像”添加回产品?这样,它们与常规页面相似。WooCommerce产品有'产品图像',但没有'精选图像'
谢谢!
更新:
这是也包含jQuery的PHP文件。该文件称为页面标题,progression.php
<?php if(is_404()): ?>
<div id="page-title">
<div class="width-container paged-title">
<h1 class="page-title"><?php _e('404 Page Not Found ', 'progression'); ?></h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php $page_for_posts = get_option('page_for_posts'); ?>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php else: ?>
<?php if(is_page()): ?>
<?php
global $wp_query;
$thePostID = $wp_query->post->ID;
?>
<div id="page-title">
<div class="width-container paged-title">
<h1><?php the_title(); ?></h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if(is_home() || is_single() && 'portfolio' != get_post_type() && 'menu' != get_post_type()): ?>
<div id="page-title">
<div class="width-container paged-title">
<?php $page_for_posts = get_option('page_for_posts'); ?>
<h1 class="page-title"><?php echo get_the_title($page_for_posts); ?></h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if(is_archive()): ?>
<div id="page-title">
<div class="width-container paged-title">
<h1 class="page-title">
<?php if (is_day()) : ?>
<?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date() . '</span>'); ?>
<?php elseif (is_month()) : ?>
<?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date('F Y') . '</span>'); ?>
<?php elseif (is_year()) : ?>
<?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date('Y') . '</span>'); ?>
<?php endif; ?>
<?php if (is_tag()) : ?>
<?php
printf(__('Tag: %s', 'progression'), '<span>' . single_tag_title('', false) . '</span>');
?>
<?php endif; ?>
<?php if (is_author()) : ?>
<?php _e('Author Archives:', 'progression'); ?>
<?php $user_info = get_userdata(1);
echo '' . $user_info->display_name . "\n";
?>
<?php endif; ?>
<?php if(post_type_exists('menu')) : ?>
<?php
printf(__('%s', 'progression'), '<span>' . single_cat_title('', false) . '</span>');
?>
<?php endif; ?>
</h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php $page_for_posts = get_option('page_for_posts'); ?>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if(is_search()): ?>
<div id="page-title">
<div class="width-container paged-title">
<h1 class="page-title"><?php printf(__('Search for: %s', 'progression'), '<span>' . get_search_query() . '</span>'); ?></h1></div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php $page_for_posts = get_option('page_for_posts'); ?>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if(is_single() && 'portfolio' == get_post_type()): ?>
<div id="page-title">
<div class="width-container paged-title">
<h1><?php the_title(); ?></h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php $page_for_posts = get_option('page_for_posts'); ?>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php if(is_single() && 'menu' == get_post_type()): ?>
<div id="page-title">
<div class="width-container paged-title">
<h1><?php the_title(); ?></h1>
</div>
<div id="page-title-divider"></div>
</div><!-- #page-title -->
<div class="clearfix"></div>
<?php $page_for_posts = get_option('page_for_posts'); ?>
<?php if(has_post_thumbnail($page_for_posts)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$("#page-title").backstretch([
"<?php echo $image[0]; ?>"
<?php if(class_exists('kdMultipleFeaturedImages')) {
if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"';
}
if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") {
echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"';
}
}
?>
],{
fade: 750,
duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
});
});
</script>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
WooCommerce仍然使用功能的图像和变化只是在界面上的“产品文图片。”你能发表你正在使用的查询代码吗? –
我添加了上面的代码。它适用于其他地方,但在产品页面上。我甚至尝试从我知道的模板(到单产品页面,这是woocommerce用来显示单个产品的页面模板)复制PHP代码,但它仍然不会显示标题图像。这让我疯狂。谢谢! – tmparisi
我假设我需要添加一个新的if语句来识别产品页面。这只是一个猜测。思考?如果这确实是正确的,那么也许你可能知道如何进行if调用? – tmparisi