WordPress.org

Ready to get started?Download WordPress

Forums

Promotion Slider
[resolved] Solution - Removing Promotions from Search Results (TwentyEleven theme) (1 post)

  1. ChromeMedia Inc.
    Member
    Posted 2 years ago #

    I am using a customized version of the TwentyEleven theme and have inserted the Promotion Slider into the header of the site.

    The trouble I ran into was the Promotion posts that are generated were showing up in search results on the site. I have the slides themselves linked to appropriate pages on the site with content relevant to the slides, but I didn't want the posts showing up in search results.

    The solution our resident PHP developer found was the following:

    In the search.php page replace this

    <?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    					?>
    
    				<?php endwhile; ?>

    With this

    <?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    				    <?php /* Exclude promotions */ ?>
    				    <?php if ($post->post_type === 'ps_promotion') { continue; }?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    					?>
    
    				<?php endwhile; ?>

    Noting specifically this line

    <?php if ($post->post_type === 'ps_promotion') { continue; }?>

    We are now able to use the search function on the site without the promotion posts showing up as results.

    http://wordpress.org/extend/plugins/promotion-slider/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic