• I am using the Custom Field Images plug-in. I placed the template tag in my sidebar.php file. After assigning the image to the custom field, it shows up in the sidebar as intended, but then ALSO in the page content as the first item. Any idea what I can do to get it to show up ONLY in the sidebar? I’ll paste my page.php code below:

    <?php
    get_header(); ?>
    
    	<div id="mid"><!-- Start Mid Content -->
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div id="item01">
                <h2><?php the_title(); ?></h2>
            </div>
    		<div class="item02">
            <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
            <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
            <?php endwhile; endif; ?>
            </div>
        </div>
    	<!--// End Mid Content -->
    
    	<?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Think you may need a second loop in the sidebar, something like this

    <?php query_posts(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    // tag goes here
    
    <?php endwhile; endif; ?>
    Thread Starter katemgilbert

    (@katemgilbert)

    Thanks gerbilk. However it didn’t fix the problem – image still showed up in post as well as sidebar. Here is the ammended sidebar.php when using the second loop:

    <?php
    /**
     * Theme : Theme Name:
     */
    
    ?>
    
    <!-- sidebar -->
    <div id="side_bar">
    
        <!--Start Dynamic Sidebar -->
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar 1') ) : else : ?><?php endif; ?>
        <!--End Dynamic Sidebar -->
    
    <?php custom_field_image() ?>
    
        <?php if(!is_front_page()): ?>
        <div class="sidebar_item01"><!--Sidebar Style 1 -->
    
    <?php query_posts(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php custom_field_image() ?>
    
    <?php endwhile; endif; ?>
        </div>
        <?php endif; ?>
    
    </div>
    <!-- // End Sidebar-->

    Any other ideas?

    What happens if you take out the first php custom_field_image ?

    <?php
    /**
     * Theme : Theme Name:
     */
    
    ?>
    
    <!-- sidebar -->
    <div id="side_bar">
    
        <!--Start Dynamic Sidebar -->
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar 1') ) : else : ?><?php endif; ?>
        <!--End Dynamic Sidebar -->
    
        <?php if(!is_front_page()): ?>
        <div class="sidebar_item01"><!--Sidebar Style 1 -->
    
    <?php query_posts(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php custom_field_image() ?>
    
    <?php endwhile; endif; ?>
        </div>
        <?php endif; ?>
    
    </div>
    <!-- // End Sidebar-->

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Placing custom field template tag in sidebar, but shows up in page too’ is closed to new replies.