I'm using the Relevanssi search plugin, which is basically a better version of the default search. Anyway when I search for something it displays everything I need it to, I was just wondering whether there would be a way to differentiate the search results for attachment pages from everything else, e.g. Display "Document: [name of attachment page]" instead of the just the name of the page?

1 Answer 1


Found out how to do it, I added the following in content.php. I added the second elseif statement and simple put the word Document in there before it displays the title of the page.

    if ( is_single() ) {
        the_title( '<h1 class="entry-title">', '</h1>' );
    elseif (get_post_type() == 'attachment' ) {
        the_title( '<h1 class="entry-title">Document: <a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
    else {
        the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.