Add a link to current page feed in wordpress page templates

Hello,
I need to manually add RSS feed links to some posts and pages on a wordpress site. I need these to be for the feeds for the individual post/category pages etc.

I know that adding /feed onto the url works to give the specific feed for that page.

Is there a wordpress function for current page url? I can't find one.

I want to add a link that would be something like this (obviously I've just put CURRENT_PAGE_URL for illustration) :

<ul>
<li class="rssNav"><a title="RSS Feed" href="<?php echo get_CURRENT_PAGE_URL(); ?>feed/"><span>RSS Feed</span></a></li>
</ul>

What's the best way to do this please?

ps. I tried just having href="/feed"  but this just shows the home page feed - domain.com/feed

Thanks
igloobobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

igloobobAuthor Commented:
OK I just found this:

// current page url

function current_page_url() {
	$pageURL = 'http';
	if( isset($_SERVER["HTTPS"]) ) {
		if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
	}
	$pageURL .= "://";
	if ($_SERVER["SERVER_PORT"] != "80") {
		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} else {
		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	}
	return $pageURL;
}

Open in new window




and then can use this in the template and it seems to work

<?php echo current_page_url(); ?>

Open in new window


Would be interested to see if this is the best way to do it before closing the question??
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason C. LevineNo oneCommented:
Are you talking about adding the comments feed for the current page?
0
igloobobAuthor Commented:
no sorry, the RSS feed (for the current page, such as 'news' or a custom post type)
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Jason C. LevineNo oneCommented:
That's not how feeds work.  

You can have a feed that is for the overall site, for a specific category or tag, or for comments (or comments on a specific post).  Merely adding /feed to the end of any page slug won't do much.

You should read the Feeds documentation:

http://codex.wordpress.org/WordPress_Feeds
0
igloobobAuthor Commented:
Hmm, ok right then. They do seem to load a feed page though for all the pages I've tried it on and these do appear to be feeds specific to those pages. I'm using on custom post type pages.
0
Jason C. LevineNo oneCommented:
Ah....terminology is important.  A custom post type is not a "page" in WordPress terms...it's a post object and thus can have its own feed as mentioned above.  The feed that is specific to a custom post type is generall for comments.  If you want an overall feed for all custom post types, you add /feed to base custom post type slug.
0
igloobobAuthor Commented:
Ah ok cool that clears it up, yes I see now I worded my initial post all wrong! I wondered why it seemed to be working!

So now we've cleared that up, would you say what I have posted in my second comment is the best way to do this? It works, just want to see if there's another way I should be doing this instead of adding a function.
0
Jason C. LevineNo oneCommented:
just want to see if there's another way I should be doing this instead of adding a function.

"Should" is a loaded word.  I don't think the WordPress gods are going to strike you down with a bolt of lightning for doing it this way.  It's a touch more complicated than it needs to be, but if it works, it works.
0
igloobobAuthor Commented:
ha OK cool thanks for taking the time with me on this thread :)
0
igloobobAuthor Commented:
I found an answer online myself so posted in here to close the question and add to the site
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.