我正在使用带有自定义主题的WooCommerce 2.1.3。自定义主题从页面抓取“特色图像”并用它来拉伸和显示标题图像(一些jQuery的东西)。重点是,WooCommerce使用“产品图片”而不是“特色图片”。我假设这就是为什么我的主题没有拿起照片并将其用于标题图片....标题仍为空白。无论如何将这个“特色图片”添加回产品中?通过这种方式,它们与常规页面相似。
谢谢!
更新:
这是包含jQuery的PHP文件。该文件名为page-title-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; ?>
答案 0 :(得分:0)
只需为产品页面创建新的if语句:<?php if(is_product()): ?>