0

I'm using the Enigma theme in my webpage and I want to hide the title of some posts without using any plugins. Every tutorial I find on the internet teaches me how to do it in a incompatible way for my theme. The TAGs of the HTML and the CSS code aren't matching with the structure of mine. So I need some help to do it.

1
  • 1
    You should include the HTML of the title, as well as the CSS that you've tried to use to hide it.
    – eddiemoya
    Commented Dec 20, 2017 at 17:13

2 Answers 2

0

If there is only 1 post showing up in your page, you could use the the_title() filter to hide the title.

The simplest way would be this:

function hide_my_title( $title, $id = null ) {

    if ( is_single( 2 ) ) {
        return '';
    }

    return $title;
}
add_filter( 'the_title', 'hide_my_title', 10, 2 );

This will hide the title when you are viewing the post with an ID of 2. Notice, this might also hide the title for another posts if some elements such as related posts are being used on this page.

1
  • That would be a elegant solution but in our case isn't totally applicable. Because hiding the text of the title would still create the tags h1 and a in the page.
    – N. Gomes
    Commented Dec 21, 2017 at 10:57
0

We found a solution for our problem making a little change in the code of the file post-content.php, line 32. Original:

<h2><?php if(!is_single()) {?><a href="<?php the_permalink(); ?>"><?php } ?><?php the_title(); ?></a></h2>

Updated:

<?php if(!is_single()) {?><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><?php } ?>

i appreciate all the help you've given me.

Your Answer

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

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