New answers tagged

0

Just hit the same thing today, but I found a great solution: <?php if ( is_front_page() ) { echo "Home"; } else if (is_single()) { // POST, not needed for my site echo ""; } else if (is_page()) { // PAGE echo get_the_title(); } else if(is_category()) { $arr = get_the_category(); if ( ! empty( $arr ) ) { ...


0

Shortened the code a little. /* * Add "title=" to previous_post_link and next_post_link */ add_filter('next_post_link', function($link) { $next_post = get_next_post(); $title = $next_post->post_title; $link = str_replace('href=', 'title="'.$title.'" href=', $link); return $link; }); add_filter('previous_post_link', function($link) { $...


0

You should be able to hook into the title by using wp_title filter function se_custom_title( $title ) { if(x == y) { $title = 'something'. $title; } return $title; } add_filter( 'wp_title', 'se_custom_titles' );


0

As per the discussion the_content is not a proper hook for filtering post titles while it filters the post content. wpautop() function is called with the_content so it adds the necessary paragraphs. To filter post titles use the_title instead, it won't add any markup tags by default: echo apply_filters('the_title', get_post_field('post_title', $post_id));...



Top 50 recent answers are included