• I have the question with one of the site work on, the problem I have is with custom post type.

    One of the templates will grab the one of my last customs post type of post feature image to be the page header image. If I remove my custom post type loop, then feature image will be back to default WP page feature image.

    How can I avoid header section pulling from my custom post type?

    ————-Here’s the code ———-
    ## footer.php ##

             </div>
    	<?php 
    	if(is_category()):
    		$cat_id=get_cat_id(single_cat_title('',false));
    		$img=get_option("taxonomy_".$cat_id);
    		$url=$img['img'];
    		else:
    		global $post;
    		$post_id = $post->ID; 
    		if(has_post_thumbnail($post_id)):
    			$url=wp_get_attachment_url(get_post_thumbnail_id($post_id));
    		else:
    			$url=get_template_directory_uri().'/img/banner.jpg';
    		endif;
    	endif;
    		?>
    <script>
        $(function() {
          $.vegas({
            src:'<?php echo $url;?>' , fade:500, 
          });
          $.vegas('overlay', {
            src:'<?php bloginfo('template_directory');?>/img/06.png'
          });
          $('.carousel').carousel()
        });
        </script>

    ## template-page.php ##
    `<div id=”test”>
    <?php
    $args=array(‘post_type’=>’services’,’meta_key’=>’level’,’orderby’=>’meta_value_num’,’order’=>’ASC’);
    $query=new WP_Query($args);
    while($query->have_posts()): $query->the_post();
    ?>
    <a href=”<?php the_permalink();?>”>
    <div class=”col-md-4 col our-services-page”>
    <?php $font=get_post_meta(get_the_ID(),’_font_image’,false);?>
    <span class=”icn <?php echo $font;?>”></span>
    <div id=”overly”>
    <?php the_post_thumbnail(‘medium’); ?>
    <?php echo get_field(‘excerpt’, get_the_ID());?>
    </div>
    <!– <img src=”<?php bloginfo(‘template_directory’);?>/img/icons.png”> –>
    <h3><?php the_title();?></h3>

    </div>
    </a>
    <?php
    endwhile;
    ?>

    </div>`

    Thanks!

    • This topic was modified 6 years, 4 months ago by madebymt.
    • This topic was modified 6 years, 4 months ago by madebymt.
    • This topic was modified 6 years, 4 months ago by madebymt.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter madebymt

    (@madebymt)

    I try to change my footer.php if else code. but doesn’t work for my current template

    if(is_category()):
    		$cat_id=get_cat_id(single_cat_title('',false));
    		$img=get_option("taxonomy_".$cat_id);
    		$url=$img['img'];
    		else:
    		global $post;
    		$post_id = $post->ID; 
    		if(has_post_thumbnail($post_id)):
    			 
     $url=wp_get_attachment_url(get_post_thumbnail_id($post_id));
            /*code I add*/
            elseif(is_page(886)):
    	$url=get_template_directory_uri().'/img/banner.jpg';
           /* end of code I add*/
    	else:
    	$url=get_template_directory_uri().'/img/banner.jpg';
    	endif;
    	endif;
    		?>

    Thank you

    • This reply was modified 6 years, 4 months ago by madebymt.
    Thread Starter madebymt

    (@madebymt)

    I find out I put <?php wp_reset_query(); ?>
    the issue will be gone. Hope that help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘page header image with custom post type’ is closed to new replies.