View Full Version : target="_blank" on main index links
Erick G
2006-06-02, 01:15 AM
Hey
Can someone tell if there is a way to set links and thumbs in the main index posts to target="_blank" so I dont have to do it manually on each post.
thanks
QuickDraw
2006-06-02, 02:39 AM
... for a specific script? I'm not following you here...
Erick G
2006-06-02, 03:25 AM
Im using wordpress and I want my mains links and thumbnails to open in a new window. I can add the code manually for each post, but would rather have it done automaticly to all my links.
ronnie
2006-06-02, 06:28 AM
Think you'd have to dig into the code, edit how the script builds the links.
ronnie
tickler
2006-06-02, 08:39 AM
You could use <base target="_blank" /> which would open all links on the page in a new window.
http://wordpress.org/support/topic/449
Erick G
2006-06-02, 12:03 PM
thanks
virgohippy
2006-06-02, 03:04 PM
If you do that ALL links open in new windows... even your navigation links.
If you're using WP it could be a bigger pain in the ass then to dig up the way it handles the content.
Maybe you could write a quick little script which writes all the code for you, and all you do is input the thumb url, the link url, and whetever, then take the output and pop it into your entry. |thumb
walrus
2006-06-02, 03:44 PM
Hey
Can someone tell if there is a way to set links and thumbs in the main index posts to target="_blank" so I dont have to do it manually on each post.
thanks
If I understand you want the links in your posts to open in a new window and not all your links to do that.
You could edit "The Loop" which starts here<?php define('WP_USE_THEMES', false); get_header(); ?>adding <base target="_blank" /> after that line. Then before the end of the loop, which looks something like this <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
you could set the base target back to self.
At least in theory, I think this should work but you may have to play with the exact location of the base target self code so that if you allow comments they don't open in a new window.
If your talking about links in a sidebar, there is a button on the bottom of the add link page that will allow you to set the link for blank
Erick G
2006-06-14, 01:06 PM
thanks walrus i think this will work.
Are you writing the posts, adding links and then having to manually add the target="_blank"?
If so:
In your 'wp-includes/js' directory is a file called "quicktags.js"
On line 371 is the code that handles the 'link' quicktag.
edButtons[i].tagStart = '<a href="' + URL + '">';
My altered code:
edButtons[i].tagStart = '<a href="' + URL + '" rel="external">';Replace the rel="external" with target="_blank" (I use the 'rel' tag with some js, because 'target' is not a valid xhtml tag.)
If not:
How are you getting the posts on your blog? There will be a way to alter the post automagically :)
http://adultweblogger.com
vBulletin® v3.8.1, Copyright ©2000-2026, Jelsoft Enterprises Ltd.