Hi,
I am using the Recent Posts widget in the sidebar of my wordpress blog.
However, I want any recent post links that are clicked to open in a NEW window as opposed to the same one.
Can anyone please tell me how I can do this?
Thanks :)
Hi,
I am using the Recent Posts widget in the sidebar of my wordpress blog.
However, I want any recent post links that are clicked to open in a NEW window as opposed to the same one.
Can anyone please tell me how I can do this?
Thanks :)
I'd advise against it, but you'd need to add target="_blank" to the links, you may need a custom widget to accomplish this.
Never a good idea for your site's links to open in new windows . . . this usually annoys people and they may not revisit your site.
Hi,
Do you know of any custom widgets that could add this attribute to the links?
no sorry I don't.
Does anyone know if the widgets.php file can be edited (or another file) to make this possible?
You can add <base target="_blank" /> to your header.php and your links will open in a new window.
Hi,
Thanks for the reply. Where in the headers.php do i add this to make my recent posts open in a new window?
At the very top like this.
<!-- header START -->
<base target="_blank" />
Thank you very much!
But is there any JUST to make recent posts from the recent posts widget to open in a new windows, and not ALL the links on my site?
What code are you using to display the "Recent Posts"?
I'm using the standard Recent Posts Widget from WordPress (found in the Widgets submenu under the Appearance menu in the Control Panel).
I don't have that widget, so I have no idea how to modify it.
If you click on the Widgets Submenu under the Appearance Tab in the WP Admin menu, it's just one of the standard widgets called Recent Posts (The most recent posts on your site).
It's after Recent Commetns and before RSS in the list of Available Widgets.
You might try finding the code that displays the links, and wrap an
<a target="_blank" </a> around it.
O.K. I figured it out.
Find the code in the sidebar that displays the links, it's should be in an h3 element. Something like this.
<h3 ><?php echo $posts_widget_title; ?></h3>
Add <base target="_blank"> Between the h3 and the php, like this...
<h3 ><base target="_blank"><?php echo $posts_widget_title; ?></h3>
That should do it.
You'll have to put an empty <h3><base target="_self"></h3> so all the links in the sidebar won't open in new window.
It won't work with the widget installed because you can't edit the widget, but you can do it in the sidebar with php.
It doesn't seem to work in IE either, but that could be due to browser settings.
Hi,
I'll have a fiddle with that code if I go for the sidebar option as opposed to the widget.
Thank you very much for all your help! :)
There is probably a way to edit the widget using your FTP client, but you'll have to figure out where it's stored on your server.
Personally, I think widgets should include a map to their locations so you can edit them if necessary. Or there should be a widget editor in WP.
Hello! What if I would like to open recent post link to a new window with different template/css format. How can I do it?
This topic has been closed to new replies.