Skip to content

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

Automattic member
mjangda commented Sep 6, 2012

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.

mfields commented Oct 25, 2012

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' ), '', '' ); 
mfields commented Nov 30, 2012

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; }

mfields commented Jan 19, 2013

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.

mfields commented Feb 27, 2013


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 Jun 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.