Add a link to current page feed in wordpress page templates

Posted on 2014-09-20
Last Modified: 2014-09-27
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) :

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

What's the best way to do this please?

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

Question by:igloobob
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4

Accepted Solution

igloobob earned 0 total points
ID: 40334262
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") {
	} else {
	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??
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40334665
Are you talking about adding the comments feed for the current page?

Author Comment

ID: 40335057
no sorry, the RSS feed (for the current page, such as 'news' or a custom post type)
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

LVL 70

Expert Comment

by:Jason C. Levine
ID: 40335479
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:

Author Comment

ID: 40335581
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.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40335746
Ah....terminology is important.  A custom post type is not a "page" in WordPress'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.

Author Comment

ID: 40336057
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.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40337190
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.

Author Comment

ID: 40337239
ha OK cool thanks for taking the time with me on this thread :)

Author Closing Comment

ID: 40347378
I found an answer online myself so posted in here to close the question and add to the site

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

WordPress has made it easy to create scalable sites based on their powerful CMS, but as great as WordPress is, there are some SEO issues that haven’t been addressed out of the box.  Fortunately these problems can be solved with a few plugins.  The f…
If you are looking for plug-ins to add functions to your WordPress small business web site, take some time to read though this comprehensive list.  These are all the plugins I use for my customers WordPress web sites, as well as my own.  Be sure to …
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question