• Resolved sergio79

    (@sergio79)


    Hi everyone,

    in a single page (not an archive) I inserted a loop of products (custom post type) with ajax filters. So I have a page structure like this:

    • /products
    • /products?tax1=myCatSlug
    • /products?tax1=myCatSlug&tax2=myTagSlug

    When I first open the /products page, the page takes the title of the sigle page, and then everything is OK.

    Now I would like to make the page /products?tax1=myCatSlug take the name of the taxonomy used as a filter. To make it work I do this:

    add_filter( 'wpseo_title', 'SeoTitleRewriter' );
    function SeoTitleRewriter($title){
        if (is_page(myPageID)){
            if (isset($_GET['tax1'])){
                 $catObj = get_term_by( 'slug', $_GET['tax1'], 'myCustomTaxSlug' );
                 $YoastSeoTitle = WPSEO_Taxonomy_Meta::get_term_meta( $catObj, 'myCustomTaxSlug', 'title' );
                 $YoastSeoTitle = wpseo_replace_vars( $YoastSeoTitle, $catObj );
                 return $YoastSeoTitle;
            }
        }
    }

    This only works if I fill in the Yoast title field for each taxonomy, if I leave the default values (eg: %%term_title%% %%sep%% %%sitename%%) I can’t read them with WPSEO_Taxonomy_Meta, which replies null.

    Is there any way to make Yoast’s default values (set in the related content type settings) work as well?

    Thank you

    • This topic was modified 1 year, 12 months ago by sergio79.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @sergio79

    Thanks for using the Yoast SEO plugin. I’m sorry we can’t provide this level of support here; it’s dedicated to offering support for the simple use of the plugin, which doesn’t include the development support you’re requesting. We can’t offer support on custom code needed to change the core features of our plugin.

    Thread Starter sergio79

    (@sergio79)

    OK thanks, in any case I await the intervention of other users who may have solved the problem in some way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get Taxonomy title structure (o wpseo title value) in a single page’ is closed to new replies.