customizing and Optimizing WordPress Blog RSS

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

  

Search for a moment, found a lot of information about WordPress theme production, but have not found WordPress blog RSS page of the production of related textbooks. When we design wordpress blog theme, we tend to forget the RSS Subscription page design, webmaster are generally using the wordpress default RSS Subscription page. In fact, we should also pay attention to the RSS Subscription page design and optimization work, perhaps now there are visitors are browsing or subscribe to our RSS. Today and everyone together to explore the customization and optimization of RSS, radish Fish also carefully prepared 4 examples, below and netizens to share.

Note: Radish fish operations are related to WordPress functions.php files, edit this file to be careful, it is best to do the backup work first.

Take a look at the radish fish in the local prepared a WordPress test platform, its RSS default page is shown below, cut a picture and the implementation of the image after a good comparison: (note, if your wordpress fixed link set pseudo static, then your RSS address is your URL /feed, if you do not have settings, address is your URL/?feed=rss2)

  

Below radish fish to add a few features for the RSS page, please go down to see:

1, to each article of the RSS to add a bit of their own characters, such as, radish fish want to at the end of each article to add a line of text to promote the site-radish home network to provide the latest WordPress information. We can do this:

Add the following code to your function.php file:

* * Add a bit of your own character to the RSS for each article * *

function Custom_feed_content ($content) {

if (Is_feed ()) {

The following $output variable is what you want to add to your text.

$output = ' radish Home network to provide the latest WordPress information ';

$content = $content. $output;

}

return $content;

}

Add_filter (' the_content ', ' custom_feed_content ');

2, to each article of the RSS add a small banner ads. We add the following code to the function.php file:

/* Add a banner to RSS for each article * *

function Feed_banners ($content) {

if (Is_feed ()) {

$output = ' <div><a href= ' # "title=" picture title "><img src=" Http://www.luoboju.com/wp-content/themes/simple_ Blog/images/luoboju.png "alt=" Here shows your banner picture "/></a></div>";

$content = $output. $content;

}

return $content;

}

Add_filter (' the_content ', ' feed_banners ');

3, for each article of RSS to increase the author and article link information, etc., this is mainly in the RSS to achieve the function of copyright declaration. You can add the following code to the function.php:

* * For each article to increase the RSS author and article link copyright information and so on * *

function Feed_copyright_disclaimer ($content) {

if (Is_feed ()) {

$permalink = Get_permalink ();

$author = Get_the_author ();

$title = Get_bloginfo (' name ');

$output = ' <p> The author of this article is '. $author. ' Link <a href= '. $title. ' > '. $permalink. ' </a> Reprint please specify .</p> ';

$content = $content. $output;

}

return $content;

}

Add_filter (' the_content ', ' Feed_copyright_disclaimer ');

4, to each article of the RSS to increase the author's more links to the article, mainly to achieve the relevant article function.

* * To add more articles to the author's RSS feed for each article * *

function Authors_post_list_in_feed ($content) {

if (Is_feed ()) {

Global $post;

$author = Get_the_author ();

$author _id = $post->post_author;

$the _posts = get_posts (' author= '. $author _id. ' &numberposts=5 ');

$output = ' <h3> more articles from '. $author. ' </h3> ';

$output. = ' <ul> ';

foreach ($the _posts as $post) {

$permalink = Get_permalink ();

$title = Get_the_title ();

$output. = ' <li><a href= '. $permalink. ' > '. $title. ' </a></li> ';

}

Wp_reset_query ();

$output. = ' </ul> ';

$content = $content. $output;

}

return $content;

}

Add_filter (' the_content ', ' authors_post_list_in_feed ');

All right, turnip fish. Currently add 4 customizations to the RSS page and we'll see what the effect of the local test looks like:

  

Focus on the exquisite WordPress theme at the same time, we should also pay attention to the optimization of RSS, through the above introduction, I hope to bring you a little help. Of course, you can also achieve more in the RSS function, radish fish in this is not one of the introduction of the description, oh, this article by Radish Home Network http://www.luoboju.com original published, reproduced please specify, thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.