Site logo

Archived topic

Remove posts (archive) page title-Why doesn't the code work?

3 replies · Started by Yumei on February 7, 2022

Viewing posts 1–4 of 4

I am testing layouts for archive pages for posts and want the page title to be gone.

I saw a code snippet in a response to someone's question earlier on a related topic, but the snippet doesn't work--why?
add_action( 'after_setup_theme', function() {
remove_action( 'generate_archive_title', 'generate_archive_title' );
} );

I also tried CSS-also no effect
.entry-title { # as well as h2.entry-title a and .entry-title a
display: none;
}

Hi Yumei,

Can you try replacing the PHP snippet you added with this one?:

add_action( 'after_setup_theme', function() {
    remove_action( 'generate_archive_title', 'generate_archive_title' );
} );

It could be that the current PHP snippet you added has syntax errors. This especially occurs if the quotation marks used are curly ones instead of straight ones.

Kindly let us know how it goes. :)

Thanks, Fernando! I made an error-I was experimenting with elements and one of them has {{entry-title}} in it. Appreciate the reminder to be careful with curly quotes!

You're welcome Yumei! Glad the issue is now resolved! Feel free to reach out any time if you’ll need assistance with anything else. :)

This archived topic is closed to new replies.