Page Links To
About
Page Links To is a plugin that allows you to make certain WordPress pages or posts link to a URI of your choosing, instead of their WordPress page or post URI. It also will redirect people who go to the old (or “normal”) URI to the new one, using a redirect style of your choosing (302 Moved Temporarily is standard, but you can enable 301 Moved Permanently redirects i f you wish.)
For instance, say you have a photo gallery installed, but can’t be bothered to integrate it into WordPress. You’ll still probably want to have a link to it from your WordPress blog. With this plugin you can create a new page called “Photos,” and give it a Custom Field links_to with the value being the URI to your photo gallery. “Photos” will show up when you use wp_list_pages();, but instead of linking to the (blank) “Photos” page, it will link you your photo gallery!
Another usage scenario is that you have content that was on a post, and want to move it to a page. You could redirect the post to the new page. And if you use a 301 redirect, search engines will eventually “find” the new location and change their links.
This plugin uses only two simple MySQL queries, no matter how many total pages or links_to enabled pages you have, so you don’t have to worry about scalability.
Usage
To redirect a page or a post, scroll down to the “Custom Fields” section on the edit screen for that entry and enter in a key of links_to with the value being the full URI you want to redirect to. If you want this to be a permanent move, you can additionally add a meta key of links_to_type with a value of “301″ (without the quotes). After saving the entry, the redirect will be active!
New in version 1.3: Now you can create a links_to_target meta key, and provide the target you would like for the link (like _new, to open the link in a new window). The target you choose will be used in wp_list_pages().
Download
Instructions
- Upgrade to WordPress 1.5.1.3 or higher (WordPress 2.0 required for tab highlighting feature)
- Upload
page-links-to.phpto your/wp-content/plugins/directory - Activate the “Page Links To” plugin in your WordPress administration interface
- Create (or edit) a page to have a title of your choosing, and a parent page of your choosing (leave the content blank)
- Down below, add a meta key of “links_to” (without the quotes) and give a full URI as its value
That’s it! Now, that page will link to the “links_to” URI instead of its WordPress page URI.
Possible Uses
- Linking to an on-site non-WordPress resource (e.g. photo gallery)
- Linking to an off-site resource (e.g. Flickr or del.icio.us page)
- Placing a link to a 2nd, 3rd, or nth level page on the top level (i.e. you might have
/archives/tags/, but want “tags” to show up on the top level) - Adding a link to your blog’s front page without having to modify your template and hack it in manually
Leave any bug reports or feature suggestions here in the comments.
Versions
- 1.4 Fixes to tab highlighting
- 1.3 You can now specify a link target via
links_to_target, tab highlighting moved to WordPress 2.0 style - 1.2 If you link to an internal WordPress page, like a category, the menu item will get the
current_itemCSS class when you’re on that page - 1.1 Posts can have redirects, can specify redirect type (301/302),
get_permalink()is filtered for posts. - 1.0 Initial public release.


Hmm, the feature itself works fine, but now every page in my Admin section starts with:
Warning: Cannot modify header information - headers already sent by (output started at /home/barry/public_html/wp-content/plugins/page-links-to.php:56) in /home/barry/public_html/wp-admin/admin.php on line 10Warning: Cannot modify header information - headers already sent by (output started at /home/barry/public_html/wp-content/plugins/page-links-to.php:56) in /home/barry/public_html/wp-admin/admin.php on line 11Warning: Cannot modify header information - headers already sent by (output started at /home/barry/public_html/wp-content/plugins/page-links-to.php:56) in /home/barry/public_html/wp-admin/admin.php on line 12Warning: Cannot modify header information - headers already sent by (output started at /home/barry/public_html/wp-content/plugins/page-links-to.php:56) in /home/barry/public_html/wp-admin/admin.php on line 13Barry, this just means that when you copy-pasted the text of the plugin, you left blank lines at the bottom. Try using the “Download” option, which will ensure that you get the original file. In any plugin, the first character should be
<?phpand the last character should be?>Any blank spaces outside of those will create that error. Because your errors happen at line 56, that’s the end of the file (which should only be 55 lines long).
Ah, that fixed it. D’oh!
Thanks!
This is a cool plugin. I used it to link to a Flickr album set slide show. Pretty cool.
Hi - I just wanted to note, that this plugin has an incompatibility with the lazy gallery plugin. Well, I don’t know the reason for this, but in my case, the pictures went wrong (error while making thumbnails) -> deactivation fixed the problem.
[sorry for bad english]
I really doubt it had to do with my plugin. I looked at that other plugin, and I don’t see anything that could be conflicting. Maybe it was just a fluke. I’d try reactivating the plugin and seeing if the error persists. If you could give me the error message generated, that would be good too.
Would be nice if the page link would be selected after the forwarding with your plugin :-/
I’m confused, can you show me an example of a meta key links_to? I’m not sure what to put on the body of the page for this to work. Thanks…
James,
The body of the page should be blank, as it will never be displayed. You want to scroll down on the Edit Page screen to the Custom Fields section, and fill in a key of “links_to” with the value being the URI you want it to point to.
Here is a screenshot that shows you what it should look like.
Thank you so much!! I feel like an idiot, it’s so easy.
Much appreciated!!
Man, this plugin is great! It’s gonna make my plans come true… And so much easier than I thought. Thanks!
First, Thanks for the pluggin. I wish I could make it work. Unfortunately I have the coder intellect of 1.86463 out of 10. I think I did everything correct, but after each page in my sidebar (and at the top of the blank page with the “link_to”) I get the following:
Warning: Missing argument 2 for txfx_filter_links_to_pages() in /”MY ROOTDIR”/views/wp-content/plugins/page-links-to.php on line 62
The MY ROOTDIR is my addition since it gives added root info I prefer not to have floating in cyberspace.
Any idea why I’d see this? Admittedly I’m a real rookie, on my second day of WordPress Themes & plugins, but I have installed about 5 other plugins without problems, incl the subscribe 0 which was how I found your site, BTW.
I’d love to get this to work. Thanks in advance.
Gary,
This plugin requires WordPress 1.5.1.3 or higher. The current version is 1.5.2, which includes several bug and security fixes, so I strongly recommend that you upgrade! I’m pretty sure that’s why you’re getting the error.
hi,
i’ve got to say this is a really great, simple way to do the redirects.
just one question - what’s the difference between the 301 and 302 type redirects? will this affect anything if i leave it as the default? i want to keep this redirect permanent… but i can’t get it to work when i put “301″ in the “Value” field…
cheers.
The main thing affected will be Google, and only if the page previously existed. With 302, Google assumes that the move is only temporary, and keeps the old URI. But again, that only matters if the previous URI was ever linked to. Using this plugin, the links are intercepted and rewritten, so if it is a new page, Google should never even see it, so the redirect is just there “in case.”
To set it up as a 301, you need TWO custom fields… one
links_tofield, and onelinks_to_typefield with a value of “301″ (no quotes).ahh… TWO fields… well that got everything working just fine. thanks!
Does your plugin work in WP 2? Or will there be a new version?
Just tested in WordPress 2.0, and it works fine!
Hi, I just tried the plugin and unfortunatley had to see, that it really does not work with WP 1.5
However, I would prefer not to upgrade because so far it runs very stable. Do you think there is annother solution to run page-links-to with WP 1.5? To fix that error on Line 62?
Appreciate your work, thx!
Regards,
Simon
doesn’t work in WP 1.5? i’ve been using this plugin for nearly a month now… absolutely no problems, and i got it working just fine.
must be a problem on your end… you’ll have to fix up that error and then it’ll work fine. but sorry i can’t really help with that error…
Thank you for the update. It works now, but I really had to update on WP 2.0, fortunately it worked without problems. Again, thx for the help and great plugin!
Mark,
I’m curious to know if there’s a way via meta key (or if it’s possible to code in the next version) to make the plug-in let you determine that links be targeted to a particular window (i.e. target=”_blank”)?
I utilize links to sub-domains on my site that I would like to have appear in new browser windows, while still being able to have other internal weblog links utilize the parent window.
TIA!
I tried setting this up on a WP 2.0 install and I get the following error …
Warning: Invalid argument supplied for foreach() in {document_root}/wp-content/plugins/page-links-to.php on line 105
Any idea’s?
i’m also very interested in adding targte to the link, is this possible?
:torgeir
That’s a good idea. I’ll get that into the next version, hopefully within the week.
Pablo,
New version is out now… version 1.3
It should fix that error. It also adds a new feature: target specification, as requested by Torgeir and Jim Mitchell.
Just use
links_to_targetto specify the target, and it’ll be used withwp_list_pages(). I’ve tested it out, and it works, but I’d appreciate feedback on that.excellent!
thanks for making the great plugin even better.
this plugin is now an important factor in making wordpress the new plattform for 2 of my sites.
Awesome, works beautifuly =)
Bravo on v1.3! It works exactly as I hoped it would! Thanks for making it available so quickly too.
Is it possible to configure the plugin to open the page in a new page so as to keep my blog open????
Yep. That’s what I just added. Use a key
links_to_targetand set it to_blankThanx! But does that mean adding that key on top of the links_to or instead???
In addition to… it still needs to know where the link goes!
OK great! works beautifully!
I’m sorry, but I’m not understanding how to use the ‘links_to_target’ command. I want to use ‘_blank’. But I don’t understand what I’m literally supposed to do to make it work.
I tried updating the key to ‘links_to_target_blank’ and that’s not working. And I can’t figure out where I’m supposed to ’set it to _blank’ or ‘in addition to’.
Can you clarify? I’d appreciate it!
Chris;
Here’s how it works…
Custom Field 1- Key; “links_to” | Value; “http://your.link.here”
Custom Field 2 - Key; “links_to_target” | Value; “_blank”
For the actual field values, do NOT use quotes around the Key or Value, and make sure there is NO page content - only the custom fields you’ve added. Hopefully that sorts it out for you.
Thanks a lot, Jim. I definitely grasp that. I’ll go do that now.
Great plugin! Exactly what I was looking for. You’ve just saved me a lot of extra work.
Hi,
I’m a Wordpress and PHP newbie. I have an integrated Gallery that I am linking to using your great plug-in.
When using the K2 theme, both the ‘Blog’ and ‘Photo Album’ tabs become highlighted when visiting the link. If I move into a sub-album, only ‘Blog’ is highlighted. How can I ensure that only ‘Photo Album’ tab is highlighted?
Will I need to make the navigation tabs static somehow?
Thanks!
I think K2 uses a hardcoded “Blog” link. You’ll have to remove that from your template and use this plugin to add it. Then it should work.
Thanks Mark, I found the hardcoded “Blog” link and modified it as you suggested. It all seems to be working fine now.
Works perfectly! Thanks!
Hi,
I was going to ask you the same question as James did, about where to put the links_to meta key thing. Thanks for putting up a screenshot so we could see exactly what to do. Your plugin is great! It worked for me and I’m quite the klutz.
Zelda.
Hi all,
Still having problems with this plugin.
I created a oage called ‘History Of Ely’ and put the ‘links_to’ to point to the page for my history posts - See screen grab here.
Now when I update this it views as intended in the admin preview of WP - See screen grab here.
This is the url that should redirect: http://www.elyonline.co.uk/history/ and it should pint to here: http://www.elyonline.co.uk/archives/category/ely-history/
But all that happens is that my 404 page kicks in.
Any ideas of what might be wrong?
Thanks
Karl
Hi!
I’ve just install Page Links To and found one ofmy problems solved. However, another one appeared.
I use WP-Pagesnav plugin, which provides an horizontal nav bar and uses few CSS classes. Unfortunately, pages added by PageLinksTo do not catch the “current” class and (its name in the bar) remain not highlighted when viewed.
I’ve tried to modify the plugin, but the following changes didn’t take effect.
[code moved to next comment]
Any idea how to fix it?
Cleaned code …
(’[]‘ substitute ”)
if ( $highlight ) {$pages = str_replace(' class="page_item current_page_item"', '', $pages);
$pages = str_replace(' [li class="page_item"][a href="' . $this_url . '"', '[li class="page_item current_page_item"][a href="' . $page . '"', $pages);
$pages = str_replace('[li class='level1'', '[li class='current'', $pages);
}
return $pages;
}
add_filter(’wp_list_pages’, ‘txfx_page_links_to_highlight_tabs’);
add_filter(’wp_pages_nav’, ‘txfx_page_links_to_highlight_tabs’);
Michal, using WP 2.0.1 or 1.5.2? Link to your site?
Karl,
Looks right. You must have conflicting plugin or mod_rewrite rules.
Mark, It’s 2.0.1.
http://www.dniskupienia.waw.pl
You can find the form at the “Zapisy” tab. I tell it just in case You don’t know Polish
Michal,
Yeah, the plugin is designed to use
wp_list_pages()… normal pages haveclass="page_item"and current pages haveclass="page_item current_page_item"Your plugin uses single quotes around the class names, for one, and also uses
class=''(blank class) for normal pages andclass=' current'for the current page. Note that there is a space. You need to replace your version for thewp_list_pages()version in my plugin, or change the class names and quote style in the other plugin.I made the plunge/switch to WordPress from Mambo. And the very first code issue that I lost sleep over was, how in the world do you do just that?, Great plug in. Thanks for your hard work man. Now I’m trying to grasp the whole picture by learning some more from the book “PHP for the world wide web”.
Hmmm disabled all plugins and checked to see if there was any additional ht access.
So I am clueless
I installed FAlbum into WordPress 2 and created a separate page called “photos”. I installed Page Links To to redirect my new page to my FAlbum page. Everything works great except that my “photos” page tab is not highlighted…”home” tab remains highlighted.
How do I solve this problem? I’m assuming I can solve it by a second meta key at the bottom of the page and have tried several ideas/combinations with no success.
By the way this is a great plugin and has potential for a lot of different uses. Thanks for your hard work.
Thanks….Jerry
Mark, thanks a lot. I got rid of the PagesNav. The reason of my installing it was a lack of knowledge of wp_list_pages power. Now I know and have used it for the upper menu
Jerry,
Change your
links_tovalue so that it is an absolute URI (withhttp://yoursite.com/) and it should work. The code is picky and wants an exact match to what is in the address bad. I’ll try to fix this in the next version.Note that if you are hardcoding your “Home” link, it will remain highlighted on your photos page. The solution to this is to remove the hardcoded link and create a “Home” page in WP and use this plugin to point it to your blog’s front page. Then my plugin will be able to unhighlight it when showing your photos page.
Thanks Mark. The absolute URI did highlight the “photos” tab , but as you suggested the “home” tab remained highlighted.
I’m a newbie so you lost me at “remove the hardcoded link”. I followed you again after that. Can you elaborate on removing the hardcoded link, or is this something beyond my capabilities?
Also under the photos page, once I click on an album to view, the photos tab goes back to unhighlighted. This problem reminds me of the carnival game where when you smack one gopher with the hammer another one pops up somewhere else.
Jerry
In your theme, you have
<ul></ul>with your “Home” page listed first, manually, and then a call towp_list_pages()You’ll need to remove that manual code. It’ll likely be in your
header.phpJust search forwp_list_pagesI’m aware of the problem with things like “Photo” pages where clicking on individual photos unhighlights the tab. This is because the URI doesn’t match exactly (could have something like
?showphoto=23or something else that is causing it not to match.) I’m trying to come up with a solution… I have a few ideas.