How to remove rel=“nofollow” from feed page

匆匆过客 提交于 2019-12-09 23:39:04

问题


In this page every link has rel="nofollow".

can you guys please tell me how to remove the nofollow from that page.

I am using WordPress them.

Hoping to receive some help from your side

Thanks in advance


回答1:


To remove nofollow from link please add the below code in your current active theme functions.php file.

The rss hook not allow to change content within tag, so create custom template for your feed.

/**
 * Deal with the custom RSS templates.
 */
function my_custom_rss() {

    if ( 'photos' === get_query_var( 'post_type' ) ) {
        get_template_part( 'feed', 'photos' );
    } else {
        get_template_part( 'feed', 'rss2' );
    }
}
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'my_custom_rss', 10, 1 );

For more help see this link : Click here.

You can get the content of custom feed templates from core wordpress folder /wp-includes/feed-rss2.php

I hope it will help you.




回答2:


Take a look at the following code snippet:

global $post;
?>
<?php if ($post->ID == $pageid): ?>
<script type="text/javascript">
$("a").each(function() {
    if ($(this).attr("rel")) {
        $(this).removeAttr("rel");
    }
});
</script>
<?php endif; ?>


来源:https://stackoverflow.com/questions/51649179/how-to-remove-rel-nofollow-from-feed-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!