• HI

    I should be able to do this.
    I have a series of custom fields that show on all my site page sidebars.
    I have a latest news box I only want to show in the left sidebar of my home page. This news box will only show if there are posts in the “front page” category.
    This all works.
    My problem is that I want to show the custom fields on the home page sidebar as well, underneath the news box. I can’t do this.
    The code I am using is:

    <?php
    if (is_page() || is_archive() || is_single() || is_home()) {//if it's any page, blog, or post or archive
    ?>
    <?php if(is_page('8')) {//if its the front page
    ?>
    <?php echo ('<img src="https://www.woodafarm.co.uk/images/Soil_Association2.jpg" width="79" height="80">');  ?>
    <?php $test=get_posts('7=test'); //if there are any posts to show on front page news cat 7
    if ($test) {?>
    			<h3>news</h3>
    			<ul>
     <?php
     global $post;
     $myposts = get_posts('numberposts=5&category=7');
     foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul> 
    
    <?php } //end of test
    ?>
    <?php   } //end of home page if
    ?>
    
    <?php $key="text1"; echo apply_filters('the_content', get_post_meta($post->ID, $key, true));//list the first custom field etc
    	?>
     <?php   } //end of any  page if
     ?>

    Why doesn’t this work???
    Thanks

  • The topic ‘How to have content B on all sidebars and content A AND B on front page sidebar’ is closed to new replies.