Conditional for 'if page 1 of post'? (7 posts)

  1. timwheatley
    Posted 6 years ago #

    Hi guys,

    I want something to display in single.php only when the visitor is viewing page 1, ie:

    I don't want it to show when they're viewing permalink/2

    I have a conditional setup right now that when I have an image url in a particular custom field, it displays a Java panoramic. But, I only want that on page 1, not on page 2, 3 etc like it is here:

  2. This should do the trick:

    $paged = get_query_var('paged');
    if ($paged < 2) {
    // you're on page 1, put your code here
  3. timwheatley
    Posted 6 years ago #


    I tried to put it into single.php but the panorama shows on all pages. Here's my code:
    $paged = get_query_var('paged');
    if ($paged < 2) { ?>

    <?php if ( get_post_meta($post->ID, 'panorama_url', true) ) { ?><center>
    <applet archive="http://timwheatley.org/global/ptviewer.jar" code=ptviewer.class width=508 height=300 alt="Please install the Java Virtual Machine plug-in from www.java.com."><param name=file value="<?php echo get_post_meta($post->ID, "panorama_url", $single = true); ?>"></applet></center><div id="footer"><center>Click on the image and move your mouse to look around.<?php if ( get_post_meta($post->ID, 'panorama_size', true) ) { ?> Size: <?php echo get_post_meta($post->ID, "panorama_size", $single = true); ?><?php } ?>
    You may also use the - and + keys to zoom in and out.</center></div>
    <?php } ?>

    <?php } ?>

  4. Try "page" instead of "paged". See if that works.

    Could be a WordPress bug there. I'm investigating.

  5. timwheatley
    Posted 6 years ago #

    That works. :)

  6. timwheatley
    Posted 6 years ago #

    Ah, one thing. It replaces the whole body of the posts page 1, not just the section I put the code around?

  7. I have no idea there. Likely you put the brackets around the wrong piece of code. The code I gave you does nothing at all, replaces nothing at all.

Topic Closed

This topic has been closed to new replies.

About this Topic