How to filter title?
-
I want to change the title based on the category. For example, if the current post is in category x or y, use title a, else use title b.
Here’s the code I tried using:
add_filter( 'related_posts_by_taxonomy_shortcode_defaults', 'related_shortcode_title', 10, 2 ); function related_shortcode_title( $defaults, $post ) { if ( has_category('44,45') ) { $defaults['title'] = 'Related Products'; } else { $defaults['title'] = 'Related Posts'; } return $defaults; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to filter title?’ is closed to new replies.