• Hi, everyone.

    I use the Business3ree Ignition theme by CSS Igniter. I have set up two categories “Tips” and “News” to filter my content in those two categories. I need to be able to change the default “Blog” text on post pages, by category.

    If you check the site you’ll see those two sections: “Tips & Tricks” and “News”. Once you click on either menu item, it will load its page, with masonry posts, which I pull using the Gutenbee plugin’s block post type: “Posts”.

    So far, each page will display the header Title text a Description (excerpt) text on each page correctly. For example, the News section will pull the posts from the “news” category and the header image text reads “NEWS” and the description reads “Testing New Section”. I want to be able to transfer the same text over the single posts coming from that section…

    However, when you click on any of the posts displayed on these pages, the main header text changes to “Blog” and the description text is gone. I know that I can set this text through the Settings–> reading on the Dashboard, but that will give all post the same text, regardless o their category. That’s why I am going with the Gutenbee Posts Block so I can separate my content, but brings this issue of not having the correct text on on posts, defined by their category. Adding the categories as menu items did not solve the issue either. I want each posts’ header image and description to be defined by its category, not by a default WordPress setting.

    CSS Igniter says that this can’t be done and that I am forced to have the word “Blog” on all my single posts and no description. I refuse to acknowledge that. How is it possible to have a header title on my posts t5hat it is not chosen by me?

    I tried to explain as best I could, given that I am not a programmer nor a WordPress expert. Thanks in advanced for your help.

    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by dographics.
    • This topic was modified 2 years, 3 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Can’t be done using the normal UI provided by your theme. But nearly anything is possible if you’re willing to dabble in some coding. The code needed might not be that complicated and possibly implemented by anyone who can manage a plain text editor.

    The first task is to determine which template is responsible for outputting the “Blog” header. The “Template Debugger” plugin can help you with that.

    Next is to identify the code on the template that actually outputs “Blog”. It needs to be changed to something else. For example, code could get the category name assigned to the current post and use that as the header title. It gets more complicated if code must decide which of several categories to use. It works better if it can arbitrarily always use the first one assigned. But nearly anything is possible if you’re willing to put in the effort.

    The main reason why this isn’t possible out of the box, is that a single post may belong to any number of categories, including none. Which is the correct category to get the title from?

    You can use the ignition_the_page_title and ignition_the_page_subtitle filters to change the text displayed there. However you will need to implement some logic according to your specific needs.

    Here is what the code looks like to get the title and subtitle out of the first assigned category (whichever order WordPress might return them):

    add_filter( 'ignition_the_page_title', function( $title ) {
    	if ( is_singular( 'post' ) ) {
    		$categories = get_the_category();
    		if ( ! empty( $categories ) ) {
    			$title = $categories[0]->name;
    		}
    	}
    
    	return $title;
    } );
    
    add_filter( 'ignition_the_page_subtitle', function( $title ) {
    	if ( is_singular( 'post' ) ) {
    		$categories = get_the_category();
    		if ( ! empty( $categories ) ) {
    			$subtitle = $categories[0]->description;
    		}
    	}
    
    	return $subtitle;
    } );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing Default Header POST Title and Description text by category wordpress’ is closed to new replies.