• Resolved Dani

    (@danicasati)


    Is there a similar snippet in SEO FRAMEWORK to edit page title?

    YOAST:

    add_filter('wpseo_title', 'custom_titles', 10, 1);
    function custom_titles() {
      global $wp;
      $current_slug = $wp->request;
      if ($current_slug == 'foobar') {
        return 'Foobar';
      }
    }

    ALL IN ONE SEO:

    add_filter( 'aioseo_title', 'aioseo_filter_title' );
    function aioseo_filter_title( $title ) {
       if ( is_singular() ) {
          return $title . 'some additional title content here';
       }
       return $title;
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Yes, here you can find a few example filters I posted on our website: https://tsf.fyi/docs/api/filters#title-related.

    Essentially, you’d want to use the_seo_framework_title_from_custom_field if you wish to overwrite the user-inputted meta title and the_seo_framework_title_from_generation if you wish to replace the generated title.

    Cheers ??

    Thread Starter Dani

    (@danicasati)

    Basically, I need to customize page title only for single product.

    • This reply was modified 2 years, 9 months ago by Dani.
    Thread Starter Dani

    (@danicasati)

    This code working in single product, but gave critical error on other pages/posts:

    if ( null === $args && is_product() ) {                                           
    		$title = $mytitle . ' [' . $vendor_name . ']';
    	} else {
            $title = $mytitle;
        }
    	return $title;
    Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    That doesn’t look like the complete code to me. Could you share the code with me with the filters and callbacks, and also the PHP error message? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Edit page title’ is closed to new replies.