Tag Info

New answers tagged

0

It turns out I just needed to return the $title variable which already had what I needed: function woocommerce_endpoint_titles( $title ) { $sep = ' | '; $sitetitle = get_bloginfo(); if ( is_wc_endpoint_url( 'view-order' ) ) { $title = 'View Order: ' . $sep . $sitetitle; } if ( is_wc_endpoint_url( 'edit-account' ) ) { ...


2

I'm not sure where this php_browser_info() function comes from. You can try the following instead: /** * Modify the front/home page title for Android devices */ add_filter( 'wp_title', function( $title ) { return ( is_front_page() || is_home() ) && isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( ...


0

The second argument for the_title is always a post ID. Use it. add_filter( 'the_title', function( $title, $post_id) { $post = get_post( $post_id ); if ( ! $post or 'your_cpt' !== $post->post_type ) return $title; return 'Test ' . $title; }, 10, 2 );


0

I am not entirely sure I understand your project but it sounds to me like you should be using the wp_title filter, instead of the the_title filter. That is fired by the wp_title() function which outputs the page title, not the titles of the posts on the page. Something like: function wpse_change_page_title( $title ) { if(is_page('some_page')) { ...


2

I believe that the page title you are talking about is the title from the page from the main query. the_title() filter (and the_content() filter for that matter) targets all the respective template tags regardless of query. To avoid this, target only the main query and the specific page. You can try the following inside your filter if ( in_the_loop() ...



Top 50 recent answers are included