Site logo

[Support request] How to change links on archive pages from dofollow to nofollow

Home Forums Support [Support request] How to change links on archive pages from dofollow to nofollow

Home Forums Support How to change links on archive pages from dofollow to nofollow

Viewing 15 posts - 16 through 30 (of 43 total)
  • Author
    Posts
  • #2516717
    Jodie

    I’ve now added the add-nofollow to the class list of the Headline Block in the Content Template element for displaying posts on archive pages.

    When I look at the page source of one of the category pages, one post that’s not supposed to have a “nofollow” attribute does have one.

    When I go into the back end of that post, and check the post meta that determines whether the “nofollow” attribute gets added, it’s unticked, as it should be.

    Do you know why this might be happening?

    Thank you so much for your help with this!

    #2517772
    Fernando
    Customer Support
    #2517834
    Jodie

    Hi Fernando

    I’ve taken some screenshots of what is happening when I add the snippet. It is attributing nofollow to a post that I definitely don’t want to be nofollow so I took it out since we were last in touch. I’ve added it in again for the purpose of showing you what is happening.

    I’ve given lots of detail below.

    Thanks so much.

    Cheers Jodie

    #2517840
    Fernando
    Customer Support

    Can you enable default value in the custom post meta settings?

    If that doesn’t work, do you have a staging site for testing?

    #2517850
    Jodie

    I’ve enabled the default value in the custom post meta settings.

    I will clear the cache on all caching plugins and Cloudflare and see what happens.

    Yes, I can set up a staging site for testing.

    Thanks so much for your prompt response.

    I’ll let you know what happens

    Cheers Jodie

    #2517854
    Fernando
    Customer Support

    Alright!

    #2517858
    Jodie

    Sadly Fernando enabling the default value in the custom post meta settings hasn’t fixed the issue.

    #2517860
    Fernando
    Customer Support

    Can you set up a staging site? Let’s check what value you post meta is returning.

    #2517864
    Jodie

    Okay shall do re staging site and then I will let you know.
    I will remove the script from my live site for now.
    Thanks so much Fernando.

    #2517867
    Fernando
    Customer Support

    Alright! You’re welcome!

    #2517889
    Jodie

    Hi Fernando

    I’ve created the staging site and added the script.

    I’ve sent you the credentials below.

    Cheers Jodie

    #2517910
    Fernando
    Customer Support

    After this line:

    $boolnofollow = get_post_meta(get_the_ID(), 'add_no_follow');

    Add this:

    var_dump($boolnofollow);

    Give these two posts different values for add_no_follow:

    Chiaogoo Vs Hiyahiya Knitting Needles Reviewed
    11 Best Interchangeable Knitting Needles [Recommended 2023]
    #2517917
    Jodie

    Thanks so much Fernando

    In the staging site I’ve added this var_dump($boolnofollow); to the Theme Functions PHP File

    I don’t know what to do when you say “Give these two posts different values for add_no_follow” what do I need to do please?

    #2517919
    Jodie

    Sorry here’s something else weird that I’m seeing on the staging site archive pages

    #2517920
    Fernando
    Customer Support

    It’s okay, I’ve got it.

    Try this instead:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'add-nofollow' ) !== false ) {
    		$boolnofollow = get_post_meta(get_the_ID(), 'add_no_follow');
                    if($boolnofollow[0]){
                       $myreplace = 'href';
    		   $myinsert = 'rel="nofollow" href';
                       $block_content= str_replace( $myreplace, $myinsert , $block_content );
                    }
        }
    
        return $block_content;
    }, 10, 2 );

    Let us know how it goes.

Viewing 15 posts - 16 through 30 (of 43 total)
  • You must be logged in to reply to this topic.