Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • whoops, typed a little fast. Here is the corrected code.

    <?php if(is_home()) : ?>
              //what I want to say on my blog
    <?php else :
          if (have_posts()) :
    	while (have_posts()) : the_post();
    	    the_content();
    	endwhile;
           endif;
    endif; ?>

    I worked up some quick code so it may be buggy as I haven’t tested it. You’ll have to use the custom fields to set the images by page number.

    <?php
       $thereisimage = get_post_meta($post->ID, image, true);
       $page = (get_query_var('page')) ? get_query_var('page') : 1;
    
       if ($page == 1) { ?>
          <img src="<?php echo get_post_meta($post->ID, image1, true); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/>
       <?php } elseif ($page == 2) { ?>
          <img src="<?php echo get_post_meta($post->ID, image2, true); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/>
       <?php } elseif { ?>
          <img src="<?php echo get_post_meta($post->ID, image3, true); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/>
       <?php } else { ?>
          <img src="<?php bloginfo('url'); ?>/default.jpg" alt="Default Image" />
    <?php } ?>

    To explain, you set you’re thereisimage variable the the page variable. If the user is on page 1 it displays the image with the image1 key, if page two the image2 key and so on and so forth until it runs out of pages or keys, then it displays the default code.

    Hope this helps.

    I’ve also done some looking around and think you’re correct for you particular case. It wouldn’t help me and you may decide to do something similar so I’m also going to post my solution.

    I needed the page text to show in the header and didn’t want to call a seperate header for the blog page so I used the following code:

    <?php if(is_blog()) : ?>
              //what I want to say on my blog
    <?php else :
          if (have_posts()) :
    	while (have_posts()) : the_post();
    	    the_content();
    	endwhile;
           endif;
    endif; ?>

    It checks to see if the user is on the blog page and shows the hard-coded text I wanted on my blog. If the user is on any other page I just display the loop to show the text I set in the admin section.

    I hope this helps.

    do you want a different image for every post or every page?

Viewing 4 replies - 1 through 4 (of 4 total)