Wordpress SEO - What are you looking for?

If you're looking for answers to SEO or wordpress related questions, type in a phrase and wait for hints or click enter! The results also show links to external sources.

161 articles in the database

Modifications to the standard WP RSS

[ Article content is protected by Plagiashield ]

wp-rss

Today, I'm going to present a few pieces of code relating to modifying the RSS feed.

Of course we put all of them in the file functions.php

Disabling the rss feed

function fb_disable_feed() {
wp_die( __('The feed has been disabled. Feel free to url') .'">pagesmain.!') );
}
add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);

Redirect feeds to Feedburner

function feed_to_feedburner_redirect() {
if ( is_feed() $$ !preg_match('/feedburner|feedvalidator/i', $_SERVER['HTTP_USER_AGENT'])){
header('Location: http://feeds.feedburner.com/[YOUR_FEED_NAME]');
header('HTTP/1.1 302 Temporary Redirect');
}
}
add_action('template_redirect', 'feed_to_feedburner_redirect');

Instead of [YOUR_FEED_NAME], insert the feed name from Feedburner

Add pages and all post types to the feed

function feedFilter($query) {
if ($query->is_feed) {
$query->set('post_type','any');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');

To limit the display to only pages for example, set the 3rd line to: $query->set('post_type','page');

Adding an entry / image icon to an RSS feed

function rss_post_thumbnail($content) {
global $post;
if( has_post_thumbnail($post->ID) )
$content = '<p>' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</p>' . $content;
return $content;
}
add_filter('the_content_feed', 'rss_post_thumbnail');

Display in RSS feed posts from a specific category

function my_home_category( $query ) {
if ( $query->is_home() &amp;& $query->is_main_query() ) {
$query->set( 'cat', '11');
}
}
add_action( 'pre_get_posts', 'my_home_category' );

To change the category ID we will use the 3rd line of code and the number in it. Currently 11.

Exclude posts with a specific tag

function feedFilter($query) {
if ($query->is_feed) {
$tags = array('11', '31', '124');
$query->set('tag__not_in', $tags); } return $query; } add_filter('pre_get_posts','feedFilter');

To change the tag ID we will use the 3rd line of code and the number in it. Currently there are tags with ID: 11, 31, 124.

Adding content after each post

function feedFilter($query) {
if ($query->is_feed) {
add_filter('the_content','feedContentFilter');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');
 
function feedContentFilter($content) {
$content .= '

Thank you for subscribing to the feed profile on https://www.facebook.com/seowordpress">Facebook!

'; return $content; }
Wojciech Wladzinski

O Wojciech Wladzinski

I have been dealing with SEO industry since 2008. At co day senior SEO specialist in the company Seogroup. I create and optimize large websites like and smaller websites online. I am particularly fond of the environment WordPresswhich, despite popular belief, is not just a blogging platform.
  • Internal Links and Sematics

  • Link building
  • Sematics
  • Link building has never been easier. Hundreds of link possibilities in one click.
  • See

[ Article content is protected by Plagiashield ]

SEMRush - the best tool for SEO and PPC.

en_USEnglish
Read previous post:
blog-google_search1
How to search more precisely in Google? [infographic].

Infografika przedstawiająca jakie typy zapytań możemy stosować w wyszukiwarce Google aby wyszukać dokładnie to czego chcemy.

Close