Tips & Tricks
Build a classic MyBlogLog widget
In this post I will show you how I created my custom widget showcasing mybloglog readers.
In your function.php
file add this simple line of code:
<?php
// MyBlogLog
function MyBlogLogWidget()
{
?>
<script type="text/javascript" src="http://pub.mybloglog.com/comm2.php?mblID=ReplaceWithYourID
&c_width=220&c_sn_opt=n&c_rows=6&c_img_size=h&c_heading_text=&c_color_heading_bg=e0e0d4&c_color_heading=E8A02C&c_color_link_bg=e0e0d4&c_color_link=d54e21&c&c_color_bottom_bg=e0e0d4"></script>
<?php }
//register the sidebar 'the widget name', 'the widget function'//
register_sidebar_widget('MyBlogLog Widget', 'MyBlogLogWidget');
?>
That’s it, just replace the “ReplaceWithYourID
” with your mybloglog ID. You can also change the width at c_width=220
to what ever you like.
If you look closely at the code you may also see color codes, you may change them to corresponding hex codes, for example: c_color_bottom_bg=e0e0d4
is the color for the bottom background. e0e0d4
is a light gray, we can change it to ffffff
and make it white.
That’s it, enjoy!
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
-
Pages2 months ago
Write For Us – Guest Post
-
Tips & Tricks1 month ago
How to: show/hide a widget in WordPress with jQuery
-
Plugins1 month ago
Top Membership plugins
-
News5 months ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks5 months ago
Limit the characters that display on the_title
-
Tips & Tricks3 months ago
Remove spaces when echoing the_title
-
Tips & Tricks4 months ago
Remove the title attribute using jQuery