Articles in the Wordpress Tutorials Category
Post Excerpts allows you to view only a part of the Post on the Home page instead of the Full Post.Displaying Excerpts has many advantages in SEO, monetisation and Traffic.Post Excerpt will give an overview to an user about what the post is all about.
The 5 Reasons for why you should use an Post Excerpt.
1 ) SEO : Google considers any similar text as duplicate content.So, if you display any post as full content on the home page as well as in the archive then, this will add to the [...]
First, you have to add the following code to your function.php file. Don’t forget to change the adsense PUB(client) id in the Code.
function showads() {
return ‘<script type=”text/javascript”><!–
google_ad_client = “pub-XXXXXXXXXXXXXXXX”;
google_ad_slot = “4668915978″;
google_ad_width = 468;
google_ad_height = 60;
//–>
</script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
‘;
}
add_shortcode(’adsense’, ’showads’);
Once you saved the functions.php file, you’re now able to embed your adsense code on your posts and display it exactly where you want. To do so, simply paste the following code on the editor, in html mode:
[adsense]
Here are the snippets of code I’ve managed to collect. If you have any WordPress code you’d like me to add, please leave a comment below!
Display Recent Posts
Here is the code you need to display the most recent 5 posts:
<?php query_posts(’showposts=5′); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>
Display Recently Updated Posts/Pages
<?php
$today = current_time(’mysql’, 1);
$howMany = 5; //Number of posts you want to display
if ( $recentposts = $wpdb->get_results(”SELECT ID, post_title FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_modified_gmt < ‘$today’ ORDER BY post_modified_gmt DESC LIMIT $howMany”)):
?>
<h2><?php [...]
Open comments.php and find the following line:
<?php foreach ($comments as $comment) : ?>
Just above this line, initialize a counter variable:
<?php $i = 0; ?>
Just after this line, increment the counter:
<?php $i++; ?>
So, your code will look like this
<?php $i = 0; ?>
<?php foreach ($comments as $comment) : ?>
<?php $i++; ?>
Now, you just have to echo the $i variable to get the number of the current comment. Paste this code anywhere on your comments loop:
<?php echo $i; ?>
Your comments are now numbered!
Feel free to ask Help !
