Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Don't show separator between meta block and Leave a Comment link in pages contained within search results. #72

wants to merge 1 commit into from

7 participants


Extra entry meta separator is present for pages visible in search results. Verify that what's being displayed is a post before outputting a separator before the Leave a Comment link

Alt text


Checking for an explicit post_type isn't friendly to custom post types. It'd be better to do "feature checking" instead via post_type_supports or other logic (e.g. does the post type have the category taxonomy registered?). The show-hide logic in the content template should probably be updated to take this into account.


I like @mjangda's approach here. Search is currently using content.php. For best results, we should make this template as post_type independent as possible.

Using if ( post_type_supports( 'comments' ) ) before we we use comments specific code seems like the best way to go.

Here's a gist I created for the taxonomies: although it should probably be brought up in a separate ticket.


well I suggest to remove pipeline for comment and put all other pipelines after link for item like tags would work fine. although "Edit" comes at last.

if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : 
         comments_popup_link( __( 'Leave a comment', 'nodiva' ), __( '1 Comment', 'nodiva' ), __( '% Comments', 'nodiva' ) ); 

         edit_post_link( __( 'Edit', 'nodiva' ), '', '' ); 

What if we only show limited meta in search results? Maybe only the title, post date, edit link, and excerpt. This would definitely fix the problem as well a create a minimal template for entries in search results which I kinda like.


It's a mean selector but get's the job done:
.search-results .type-page .sep:first-child { display: none; }


It seems a little strange that we would include markup that's meant to be hidden by default.


@mfields I like the idea of showing limited meta for search results, too. Including extra meta (like the comment count) probably isn't relevant for most search cases. Makes it easier to browse the results and find the desired information.


@mfields We don't, it only gets hidden in search. We already do it with authors on single author sites.



I thing that the best programatic solution here would be overreaching:

  1. Capture all meta in an array.
  2. Join the meta array into a string with the separator.
  3. Echo to the screen.

Something like this would ensure that the separator is never rendered at the beginning or end of the string. This would result in non-template style code that incorporated output buffering for the template tags that do not return a value.

There's another solution via Twenty Thirteen which removes all non-post meta from pages in search:

Twenty Thirteen Search Template with Mixed post types

This is made possible by having all of the post format template accounted for content.php is then used only for pages + custom post type that appear in mixed post type templates.

I also want to note that Twenty Thirteen does not include the separators - I think that this could be a very good way to fix this ticket too.


Why not just rename $tax to $meta, add the result of get_edit_post_link() (wrapped in the edit-link span), and then use implode('</span> | <span class="sep">', $meta). I kind of thought that's what he meant.


The plan is to remove/replace the pipe altogether, and eventually merge @obenland's templating fixes.

@obenland obenland closed this in 514b2aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 4, 2012
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 2 deletions.
  1. +4 −2 content.php
6 content.php
@@ -52,8 +52,10 @@
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
- <span class="sep"> | </span>
- <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) ); ?></span>
+ <?php if ( 'post' == get_post_type() ) : ?>
+ <span class="sep"> | </span>
+ <?php endif; // End if 'post' == get_post_type() ?>
+ <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) ); ?></span>
<?php endif; ?>
<?php edit_post_link( __( 'Edit', '_s' ), '<span class="sep"> | </span><span class="edit-link">', '</span>' ); ?>
Something went wrong with that request. Please try again.