Removing date from pages not posts in search results (Wordpress) -
i'm trying remove date pages in search results.
i found this: https://wordpress.org/support/topic/search-results-hide-date-for-pages-not-posts - however, can't seem figure out add without causing errors.
i found answer suggesting removing date code page.php don't have in there anyway.
my search.php:
<?php get_header(); ?> <?php get_sidebar(); ?> <div id="content"> <div class="article"> <?php $wp_query->query_vars["posts_per_page"] = 16; $wp_query->get_posts(); ?> <?php if ( have_posts() ) : ?> <?php global $wp_query; $total_results = $wp_query->found_posts; ?> <?php printf( __( 'search results for: %s', 'shape' ), '<span>' . get_search_query() . '</span>' ); ?> <br/><br/> <?php /* start loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <div class="searchresultsdate"> <?php the_time('m j, y') ?> </div><div class="searchresults"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></div> <?php endwhile; ?> </div> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?> <div class="right"><?php next_posts_link('next page »') ?></div> <div class="left"><?php previous_posts_link('« previous page') ?></div> <?php } ?> <br><br><br> <?php else : ?> <div class="posttitle">nothing found. try else?</div> page doesn't exist <?php endif; ?> <?php get_footer(); ?>
change
<div class="searchresultsdate"> <?php the_time('m j, y') ?> </div>
to
<?php if ("page" != get_post_type()){ ?> <div class="searchresultsdate"> <?php the_time('m j, y'); ?> </div> <?php } ?>
also you're missing ';' in many places.
Comments
Post a Comment