Quantcast
Channel: Topic Tag: action | WordPress.org
Viewing all articles
Browse latest Browse all 892

Remove category archive header if category description is empty

$
0
0

I need the header (header class page-header) to be unset if there is no category description. However the code I have is not working.

function empty_cat_desc_disable_heading() {
  	$term_description = term_description();
  	$category_description = category_description();
	if ( is_archive() && empty( $category_description )  ) {
		remove_action( 'generate_archive_title','generate_archive_title' );
	}
  return;
}
add_action( 'wp', 'empty_cat_desc_disable_heading' );

I read here https://wordpress.org/support/topic/remove-entry-header-from-post-template-and-change-titles-displayed-on-blog/#post-11042811 that it could be because the code needs to run a little later. So as a test I only used this code:


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

However that did nothing either – all the headers were still there. :/


Viewing all articles
Browse latest Browse all 892

Trending Articles