Connect with us

Tips & Tricks

How to: Open external links in a new window

Published

on

Over the weekend, I attended WordCamp Denver, and I was asked by John Hawkins how to force links to open in a new tab with out editing the source code. So, today lets learn a simple jQuery trick to open all external links in your site in a new tab or window. We are going to make sure you have jQuery active on your site, you can do this easily in WordPress, since it’s bundled with the latest installations. Use this code in your header: <?php wp_enqueue_script('jquery'); ?> then, below the wp_head add the following:

<script type="text/javacript">
var $j = jQuery.noConflict();

$j(document).ready(function() {
//external attribute
    $j("a:not([@href*=http://YOURSITE.com/])").not("[href^=#]")
        .addClass("external")
        .attr({ target: "_blank" });
    }
);
</script>

That’s it, just make sure you change the http://YOURSITE.com to your website.

Update

If you like you can remove the var $j = and replace all $j with simply just $

 

Tips & Tricks

Display custom url if comment authors url is blank

Published

on

Here is a nifty trick for your comments.php template. If someone comes to your site and leaves a comment but doesn’t leave a url back to there site, the default link that is shown in place of the php code comment_author_url is the current page link.

That might not look good. So, here is a little trick that I just implemented into my site. Besides installing the twittar plugin and pulling Twitter avatars I wanted to use the image itself for the authors url like. But if the author doesn’t have a Twitter avatar or a Gravatar it will display a default Gravatar that I set. If the default Gravatar is shown, usually the author will not leave a url link.

I would like to link the image to Gravatar.com so that they can get an image attached to their email address. So.. here is the code:

<?php if($comment->comment_author_url != "") { ?>
<a href="<?php comment_author_url(); ?>"><?php gravatar(); ?></a>
<?php } else { ?>
<a rel="nofollow" href="http://gravatar.com" title="Get a Gravatar today!"><?php gravatar(); ?></a>
<?php } ?>
Continue Reading

Tips & Tricks

Echo custom fields in any category

Published

on

Here is a neat trick. Say you want to show a custom field in you post or in a certain categories post. There is a simple code you need to write in order to accomplish this:

<?php $image = get_post_meta($post->ID, "image", $single = true); ?>
<?php if($image != '') : if(in_category(7)) { echo ''; } else { ?>
<img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>

In the example above I am calling the variable $image and telling the server that it equals the value of “image” inside get_post_meta or “custom field” of the current post.

Then we are asking if that variable $image doesn’t equal nothing or != and if it is in the category id of 7, echo what ever is in the single quotes (which is nothing in this example), otherwise show the <img> and the value inside “image” which should be the location of the image.

Update: Thanks to Austin from PressedWords for pointing out his trick, from the comment below.

Continue Reading

Tips & Tricks

Disable caching of your site or post

Published

on

I talked about Disabling search engine on search pages in a previous post using the meta tag. Today lets go over the web bots Cached copy of your site. If you are working on builder your blog, or have a temporary site up, use the following code:

<meta name="robots" content="noarchive">

This will tell any bot to follow your site, index it, but prevents a cached copy of this page from being available in the search results.

Continue Reading

Random Search Terms

Title

Top Articles

Top Searches

powered by WassUp

Recent Posts: Fully Net Worth . com

Bandhunta Izzy Net Worth: How Rich is the Rapper in 2019?

Bandhunta Izzy Net Worth: How Rich is the Rapper in 2019?

Israel Jordan James, who is better known by his stage name as Bandhunta Izzy, is an American rapper who is best known for songs such as “BBB,” “Rumors” and “I Got It”. The young rapper is currently signed with Universal Republic Records. As of 2019, Bandhunta Izzy net worth is estimated to be $700,000. James […]

Teejayx6 Net Worth: How Rich is the Rapper Teejayx6 Actually?

Teejayx6 Net Worth: How Rich is the Rapper Teejayx6 Actually?

Teejayx6 is an emerging American rapper who has recently become a viral sensation for his scam-based songs about identity theft and credit card fraud. The song that was a big success and conveyed this message was called “Dark Web”. As of 2019, Teejayx6 net worth is estimated to be $250,000. He has never revealed his […]

Jade Cline Net Worth: How Rich is the Teen Mom star Actually?

Jade Cline Net Worth: How Rich is the Teen Mom star Actually?

Jade Cline is a TV personality who is best known for being a part of different MTV shows including “Teen Mom” and the “Young and Pregnant”. She replaced Jenelle Evans in the second half of Season 9 of Teen Mom 2. As of 2019, Jade Cline net worth is estimated to be $150,000. Jade was […]

Trending

%d bloggers like this: