• Resolved flaschenzug22

    (@flaschenzug22)


    I have the problem, that the same title is display on every taxonomy page.
    I created an archive page template file, which is responsible for this specific taxonomy.

    The cpt on this page should be:
    https://inn-aktiv.at/angebote/schwimmbaeder/ -> Schwimmb?der – Angebote – Inn-Aktiv
    https://inn-aktiv.at/angebote/freizeitangebote/ -> same here

    The YOAST preview shows the correct title:
    Schwimmb?der – Angebote – Inn-Aktiv

    I tried to replace the %%term_title%% like this:

    // define the wpseo_replacements callback
    function filter_wpseo_replacements( $replacements ) {
        if( isset( $replacements['%%term_title%%'] ) ){
            $replacements['%%term_title%%'] = 'test';
        }
        return $replacements;
    };
    // Add filter
    add_filter( 'wpseo_replacements', 'filter_wpseo_replacements', 10, 1 );

    It looks like the %%term_title%% variable is just not set on the archive page, but the wordpress backend knows how to translate it?

    Anyone any ideas? Thanks a lot!

    • This topic was modified 2 years, 7 months ago by flaschenzug22.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello Flaschenzug,

    Thanks for reaching out about creating custom template variables.

    Did you follow this help article on creating custom template variables in WordPress but still need further help? Unfortunately, I am unable to review your code. If you have an active Yoast SEO Premium subscription or if you can consider buying one, we can investigate the issue further. However, if you don’t wish to get the Yoast SEO Premium subscription, that’s completely fine. In this case, you’ll need to troubleshoot the issue further on your setup. So, someone from the community might step forward as well who has experienced or is familiar with the issue.

    Thread Starter flaschenzug22

    (@flaschenzug22)

    Thanks for your help @maybellyne .
    With your link I was able to define a new variable and to display it in the title Tag. So everything is working now.

    There is only one thing that I do not understand.

    the function change_term_name() is called 5 times.
    So if I uncomment this line (in the code below):
    echo "test -> ".get_queried_object()->name."<br>;
    I get the following output:

    test -> Nachhaltig & ?kologisch
    test -> Nachhaltig & ?kologisch
    test -> Nachhaltig & ?kologisch
    test -> Nachhaltig & ?kologisch
    test -> Nachhaltig & ?kologisch

    Any ideas why this is happening? I assume it should be called only once.

    Here is the code I used. Just if anyone needs it too.

    // change term name in title
    function change_term_name(){
        if(is_tax('themen')) {
            // echo "test -> ".get_queried_object()->name."<br>;
            return get_queried_object()->name;
        }
        else return '';
    }
    // define the action for register yoast_variable replacments
    function register_custom_yoast_variables() {
        wpseo_register_var_replacement( '%%thema-title%%', 'change_term_name', 'advanced', 'some help text' );
    }
    add
    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    We aren’t able to provide or comment on your custom code on the implementation of the wpseo_register_extra_replacements filter for the custom snippet variables as it’s outside of our scope of support and would need more technical review, but we’ll leave this thread open for a few days to see if any other users would like to make suggestions or provide advice further.

    Thanks in advance!

    Plugin Support Maybellyne

    (@maybellyne)

    Hi,

    This thread has been marked as resolved due to a lack of activity.

    You’re always welcome to re-open this topic. Please read this post before opening a new request.

    Thanks for understanding!

    Thread Starter flaschenzug22

    (@flaschenzug22)

    not even close to be solved … but whatever

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘The same term_title is displayed on all archive pages’ is closed to new replies.