WP Canyon did wonderful tricks, this tricks is about how to automatically create a custom field when a post is published. This wonderful method is added some code on your functions.php files on your current theme.
Read the rest of this entry »
WP Canyon did wonderful tricks, this tricks is about how to automatically create a custom field when a post is published. This wonderful method is added some code on your functions.php files on your current theme.
If you are WordPress fanatics, there is some reason why we need to added extra classes on some WordPress standard code. Example we need adding extra classes and other attributes on previous_post_link() and next_post_link().
To do this WP Tricks, we need to create some function on our functions.php, the function we need is to added the code with add_filter method. Follow this tricks
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes()
{
return 'class="styled-button"';
}
Cats Who Blog write nice code, the function of this code is How to display your average feed and readers. I’ll re share this code for you and we hope you like it.
Before we started to code, we need to prepare text editor such as Coda, TextMate, Text Edit, Notepad++ or whatever you like. Then open your functions.php in your themes files and write down.
function get_average_readers($feed_id,$interval = 7){
$today = date('Y-m-d', strtotime("now"));
$ago = date('Y-m-d', strtotime("-".$interval." days"));
$feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed_url);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
$nb = 0;
foreach($xml->feed->children() as $circ){
$nb += $circ['circulation'];
}
return round($nb/$interval);
}
There are so many way to attract visitor on your WordPress blog, the one of them is show most popular post on your sidebar or footer, beside that fact in order to help your visitors finding your best content.
Let’s me share “How to get most commented posts along with their related thumbnail“, This trick need little bit code to be written on your themes files. I will show you how to do this. The first time, open your sidebar.php or footer.php or whatever files with your favorite editor. Then write down this code
<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>
<?php while ($popular->have_posts()) : $popular->the_post(); ?>
<?php $justanimage = get_post_meta($post->ID, 'thumbnail', true);
if ($justanimage) { ?>
<img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" />
<?php } else { ?>
<img src="http://an-alternative-image.jpg" alt="" />
<?php } ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>
Get Recent Comment with Gravatar without plugin
January 24th, 2010 By WP Tricks Posted in TipsMany WordPress User need to display Recent Comment on the sidebar or footer with Gravatar, most of them using plugin, right now I will show you how to Get Recent Comment with Gravatar without plugin. All need to do just write little bit of code and modified as many you want and you need.
On our recent article, I was cover tips to display most commented post with gravatar without plugin, and I hope you’ll enjoy this tricks too, because this trick also simple and of course useful.
Let’s get started, open your sidebar.php or footer.php or whatever files you need to display recent comment and add this code
<?php $query = "SELECT * from $wpdb->comments WHERE comment_approved= '1' ORDER BY comment_date DESC LIMIT 0 ,5"; $comments = $wpdb->get_results($query); if ($comments) { echo '<ul>'; foreach ($comments as $comment) { $url = '<a href="'. get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID .'" title="'.$comment->comment_author .' | '.get_the_title($comment->comment_post_ID).'">'; echo '<li>'; echo '<div class="img">'; echo $url; echo get_avatar( $comment->comment_author_email, $img_w); echo '</a></div>'; echo '<div class="txt">Par: '; echo $url; echo $comment->comment_author; echo '</a></div>'; echo '</li>'; } echo '</ul>'; } ?>Read the rest of this entry »
Amazing Touch
Tags: Code, Comment, Gravatar, Guide, Recent
19 Comments