0

I'm making a custom archive / category page using WooLentor and Elementor.The only thing I really need is a dynamic title. What I mean by that is that I have 5 categories. Now, if I open category 3, I would want to see title Number 3, and if I open category 5, I would want a title saying Number 5.

Jazzu
  • 33
  • 7

1 Answers1

0

Added this to functions.php:

    function page_title_sc( ) {

    $title = ('Page Title');

    if ( is_page() || is_singular() ) {
        $title = single_post_title();
    } else if ( is_category() ) {
        $title = single_cat_title( '', false );
    } else if ( is_tag() ) {
        $title = single_tag_title( '', false );
    } else if ( is_author() ) {
        $title = '<span class="vcard">' . get_the_author() . '</span>';
    } else if ( is_post_type_archive() ) {
        $title = post_type_archive_title( '', false );
    } else if ( is_tax() ) {
        $title = single_term_title( '', false );
    }

   return apply_filters( 'page_title_sc', $title );
}
 
add_shortcode( 'page_title', 'page_title_sc' );

After that just use [page_title] shortcode.

Thanks for helping me out

Jazzu
  • 33
  • 7