• Resolved nanonanouk

    (@nanonanouk)


    Hi,

    Are the filters wpseo_prev_rel_link and wpseo_next_rel_link as described in the link below now removed?

    https://yoast.com/wordpress/plugins/seo/api/

    I was wanting to use them and in conjunction with wpseo_canonical to make the links non-ssl versions, is there any other way to do this?

    Kind regards
    Scott

    • This topic was modified 8 years, 2 months ago by nanonanouk.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Sa?a

    (@stodorovic)

    Hi @nanonanouk

    Filters exist. You can see:

    https://github.com/Yoast/wordpress-seo/blob/trunk/frontend/class-frontend.php#L1136

    I’m not sure that you are going in right direction. What exactly you want to change?
    You can’t change only canonical URL, sitemap uses other filters and there are possible inconsistencies if you do it on this way.

    Thread Starter nanonanouk

    (@nanonanouk)

    Hi @sa?a

    Thanks for your reply and linking to the code, explains why my grep didn’t find it!

    My site is served as both http and https, it’s optional, I let the user decide but wanted to make sure I’m not getting duplication in google so was going to use the filters to set the rel canonical, next and prev to always be the http version which is the one I want google to index. Sitemap is okay as that is always has http links for both.

    This is my code, any ideas why it wouldn’t work for next/prev? canonical converts to http fine.

    function set_link_non_ssl($url) {
            $url = preg_replace("/^https:/i", "http:", $url);
            return $url;
    }
    add_filter( 'wpseo_canonical', 'set_link_non_ssl' );
    add_filter( 'wpseo_prev_rel_link', 'set_link_non_ssl' );
    add_filter( 'wpseo_next_rel_link', 'set_link_non_ssl' );

    Kind regards
    Scott

    • This reply was modified 8 years, 2 months ago by nanonanouk.
    Sa?a

    (@stodorovic)

    It’s simple explanation. Your regexp matches only url at the begin (position 0). Filter wpseo_canonical contains only URL, but rel_link filters contains entire line (https isn’t at the begin). My advice is to use str_replace, it’s faster and it’s only one line so you can’t replace something wrong.

    function set_link_non_ssl($str) {
            return str_replace( 'https://', 'https://', $str);
    }

    I replaced url with str to we avoid confusion.
    I think that isn’t enough to avoid duplicate content. Maybe you should do some redirects, I’m not sure. (You can use filter template_redirect if you need to do it)

    Thread Starter nanonanouk

    (@nanonanouk)

    That’s working great now ?? Thankyou so much for your time. Have a loverly Xmas!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wpseo_prev_rel_link and wpseo_next_rel_link missing?’ is closed to new replies.