• Hi everyone,

    I have a few articles that are broken into multiple pages using the <!–nextpage–> tag. I also have an image header which I use on every post through custom field.

    My question is, how do I change the image header to a different one if the article is on page 2 or 3?

    Is there a condition that I could use? I looked at page, paged, and numposts but I couldn’t get any to work correctly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • This checks if it’s paged:

    <?php
    
    global $wp_query;
    
    if((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
    
    // Do something if paged
    
    }
    
    ?>
    Thread Starter Vietson

    (@limited)

    Thanks for the reply. I was able to get the code working for page 2, and so on, but I couldn’t get it to work for page 1.

    Here’s the code I have…

    <?php
    	if	(( ($page = $wp_query->get('paged')) || ($page = $wp_query->get('page')) ) && $page == 1 && get_post_custom_values("img"))	{ /* Display Image Header 1*/ }
    	elseif	(( ($page = $wp_query->get('paged')) || ($page = $wp_query->get('page')) ) && $page == 2 && get_post_custom_values("img2")) 	{ /* Display Image Header 2*/ }
    	elseif	(( ($page = $wp_query->get('paged')) || ($page = $wp_query->get('page')) ) && $page == 3 && get_post_custom_values("img3")) 	{ /* Display Image Header 3*/ }
    ?>
    Thread Starter Vietson

    (@limited)

    Ahh, I finally got it to work.

    <?php
    	if	(( ($page = $wp_query->get('paged')) || ($page = $wp_query->get('page')) ) && $page == 2 && get_post_custom_values("img2")) { /* Get Img 2 */ }
    	elseif	(( ($page = $wp_query->get('paged')) || ($page = $wp_query->get('page')) ) && $page == 3 && get_post_custom_values("img3")) { /* Get Img 3 */ }
    	elseif	(get_post_custom_values("img")) { /* Get Img */ }
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Article with Multiple Pages!!’ is closed to new replies.