Forums

[resolved] How can I add the pages to my RSS feed? (11 posts)

  1. svedish
    Member
    Posted 9 months ago #

    Hi guys,

    I hope someone will be able to help me with a simple question (not so simple for me obviously!).

    One of my websites is made of pages and posts as well. I use pages for static longer articles and posts for short news and I'm happy with the structure of it so that's not going to change.

    Now, I'd be great if the people and websites that are subscribed to my RSS feed could receive updates also when I write a new article (page). Can anyone please tell me how to achieve this? I'd like to either include the pages feed inside the main feed or create another pages feed. The first option would be better to be honest so I have one big feed for everything.

    I'd also like to stay away from plugins if possible. Can anyone suggest something that could be achieved, for example, in the functions file or any other part of the code?

    Big thanks! :)

  2. duck__boy
    Member
    Posted 9 months ago #

    If you want multiple feeds -

    http://yourdomain.com/feed/ (will show only posts)
    http://yourdomain.com/feed/?post_type=page (will show only pages)

    If you want one condensed feed -

    Add this to your functions.php file -

    add_filter('request', 'feed_request');
    function feed_request($qv){
    	$rss_post_types = array('post', 'page');
    	if(isset($qv['feed']) && !isset($qv['post_type']))
    		$qv['post_type'] = $rss_post_types;
    	return $qv;
    }

    now this is your feed URL -

    http://yourdomain.com/feed/ (will show both posts and pages)

  3. svedish
    Member
    Posted 9 months ago #

    Genius! Thanks.

    I hate the idea of using addons for every little thing. I'll see how this works out. And also thanks for pointing out how the query in the URL works. Basically the feature is already there. At the end of the day pages are posts types! That's right. :)

    Thanks again, really appreciated.

  4. svedish
    Member
    Posted 9 months ago #

    By the way, a slightly unrelated question. Adding the pages to the feed exposed a page (friends links) where I have added links to directories and stuff like that. I really wanted to keep this page hidden from Google. Is there any way to exclude this page from the feed? Or is it maybe better to use a different template for it and maybe use a robots noindex tag in it?

    Thanks a lot.

  5. duck__boy
    Member
    Posted 9 months ago #

    Adding 'noindex' should work, but it is of course a pain to have to have two separate templates. I can't think of a way of doing it through the request action off the top of my head, but it is a good question and I may well have to research that a little.

    One thought - add a filter to your header.php file for the re event text and then just alter it through the filter on the pages where you don't want Google to index them? Hope that makes sense!

  6. svedish
    Member
    Posted 9 months ago #

    Hello,

    thanks for your answer and sorry, no, I'm not sure I understand what you mean re: the filter in the header.php. Soz :)

  7. duck__boy
    Member
    Posted 9 months ago #

    Ok, Im on my tab with no code at the mo, I'll try and take 5 to post a quick example when I'm in the office tomorrow - it should hopefully be pretty straight forward!

  8. svedish
    Member
    Posted 9 months ago #

    hi Duck Boy, that's very kind. Cheers :)

  9. duck__boy
    Member
    Posted 9 months ago #

    Hmm, it looks easier than I first though...

    add this to your functions.php file -

    function make_page_noindex(){
    	echo '<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">';
    }

    and this to your page.php file just above get_header(); (or what ever template you want it in, obviously changing 69 for your desired page ID) -

    if(is_page(69)) :
    	add_action('wp_head', 'make_page_noindex');
    {
    endif;
  10. svedish
    Member
    Posted 9 months ago #

    You're absolutely right! Thanks a lot. Take care. :)

  11. duck__boy
    Member
    Posted 9 months ago #

    You are welcome - and could you please mark this thread as 'Resolved' on the right.

    Thanks.

Reply

You must log in to post.

About this Topic