Tips & Tricks
Add a shortcode
This is a simple one.
/** * Your Blog title * */ function my_blog_title() { $blogname = get_bloginfo('name'); return '<span class="blog-title">' . $blogname . '</span>'; } add_shortcode('blog-title', 'my_blog_title');
Just add this to your functions.php file and then add [blog-title] in any post or page and it will return your Blog Title. :)
Tips & Tricks
Echo custom fields in any category
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.
Tips & Tricks
Disable caching of your site or post
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.
Tips & Tricks
Disable search engine on search pages
A good idea when trying to get the most out of your blog is usging the meta tag to tell the web bots to search & index your site. But for good SEO you should apply this code in your header.php
file of your WordPress blog.
<?php if(is_search()) { ?> <meta name="robots" content="noindex, nofollow" /> <?php }?>
This will keep your site from getting a hit from bots over duplicate entries. 🙂
-
Tips & Tricks2 months ago
WordPress Security Hacks
-
Pages5 months ago
Write For Us – Guest Post
-
Showcase5 months ago
StylizedWeb.com
-
News4 months ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks4 months ago
Remove the title attribute using jQuery
-
Tips & Tricks1 month ago
How to: show/hide a widget in WordPress with jQuery
-
Plugins4 weeks ago
Top Membership plugins
-
Tips & Tricks5 months ago
Limit the characters that display on the_title
You must be logged in to post a comment Login