[Support request] Page title in block element – problem

Home Forums Support [Support request] Page title in block element – problem

Home Forums Support Page title in block element – problem

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1612272
    Tomasz

    1. I’m having trouble generating the page title in header. I use the block element for the header – on every page, excluding the start page. I am using the code to get the title shortcode:

    add_shortcode( 'page_title','tu_page_title_shortcode' );
    function tu_page_title_shortcode()
    {
        return get_the_title();
    }

    Everything is ok on the subpages and in the articles, however, the Blog shows the name of the first article instead of the name of the category. How to fix it?

    2. what is the shortcode to display the category description?

    3. I also have a question, how can I hide the display of the post / page title, description (eg. category) in the content (I want it to be displayed only in the header)

    #1612545
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    1. You’ll need to do something like this:

    if ( is_home() ) {
        return 'Blog';
    } else {
        get_the_title();
    }

    2. You’ll want to use this function to get the term description: https://developer.wordpress.org/reference/functions/term_description/

    3. You can disable the content title using a Layout Element: https://docs.generatepress.com/article/layout-element-overview/

    To disable the term title/description, you can do this:

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

    Hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.