[Support request] Add nofollow attribute to links in element >block> site footer

Home Forums Support [Support request] Add nofollow attribute to links in element >block> site footer

Home Forums Support Add nofollow attribute to links in element >block> site footer

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2296075
    Rostyslav

    Hello,

    I have created a block element site footer and I would like to add attribute to some of the links like “Privacy Policy”. I can’t find that option in the editor.

    How can I achieve that?

    Thanks

    #2296513
    Ying
    Staff
    Customer Support

    Hi there,

    The privacy policy in your site footer seems added using a menu list block.

    If so, GP has no control over it.

    I would suggest using the GB buttons block to manually add links so that you can edit the attribute individually for each link.

    #2296598
    Rostyslav

    Hello!

    Even if I add a generateblocks tittle the option is not available. It is causing GeneratePress. Video https://www.loom.com/share/42c213627f5343049c4a4612be2cfce3

    #2296727
    Fernando
    Customer Support

    Hi Rostyslav,

    Try adding add-nofollow to the class list of the Headline Block in its advanced settings.

    Then, add this snippet:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && 'generateblocks/headline' === $block['blockName'] && ! empty( $block['attrs']['className'] ) && 'add-nofollow' === $block['attrs']['className'] ) {
            $block_content = str_replace( '<a ', '<a rel="nofollow" ', $block_content );
        }
    
        return $block_content;
    }, 10, 2 );

    Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.