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.
Page URL is https://moja-savna.si/
Hope someone manages to help me out.
Kind regards
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.