Latest News
Home » All Blogger Tips » 6 Useful Front End WordPress Tips and Tricks
web development, SEO services, Web designing

6 Useful Front End WordPress Tips and Tricks

6 Useful Front End WordPress Tips and TricksWord press is a famous online content management system. We everybody loves word press and using it for our blogging. We all of people are using its default settings. But most of the people don’t know how to customize it according to our needs.
Here I am giving you some useful word press front end tips and tricks. It will help you to customize your word press websites posts and pages. And also it will enhance user experience and will create a great impression for your readers or for visitors. Please backup your website first.

6 Useful Front End WordPress Tips and Tricks

1. Change excerpt length

If you are a blogger or as usual visitors then you will see that many website owners uses excerpt for displaying posts in their homepage. It helps to showing first some lines of posts that’s websites owners want to show for their readers. Add these following lines on your functions.php file with the value 75 as the excerpt length.

add_filter(‘excerpt_length’, ‘my_excerpt_length’);
function my_excerpt_length($len) { return 75; }

2. Add Read More permalink to the end of the excerpt

For adding read more permalink to the end of the excerpt you need to add this code on you themes functions.php file

function excerpt_readmore($more) {

return ‘… <a href=”‘. get_permalink($post->ID) . ‘” class=”readmore”>’ . ‘Read More’ . ‘</a>’;
}
add_filter(‘excerpt_more’, ‘excerpt_readmore’);

3. Create Meta description from the content automatically

Sometime it is boring to create Meta description for each post. For this reason add this code on functions.php file also ensure that you add this on header.php or snippet will not function.

function create_meta_desc() {
global $post;
if (!is_single()) { return; }
$meta = strip_tags($post->post_content);
$meta = strip_shortcodes($post->post_content);
$meta = str_replace(array(“\n”, “\r”, “\t”), ‘ ‘, $meta);
$meta = substr($meta, 0, 125);
echo “<meta name=’description’ content=’$meta’ />”;
}
add_action(‘wp_head’, ‘create_meta_desc’);

 

4. Replace content words by affiliate links automatically

If you want to replace content words with affiliate links then simply paste this code on your themes functions.php file. And change the words or links as your necessity.

function replace_text_wps($text){
$replace = array(
// ‘WORD TO REPLACE’ => ‘REPLACE WORD WITH THIS’
‘thesis’ => ‘<a href=”http://mysite.com/myafflink”>thesis</a>’,
‘studiopress’ => ‘studiopress’
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}

add_filter(‘the_content’, ‘replace_text_wps’);
add_filter(‘the_excerpt’, ‘replace_text_wps’);

5. Show related posts without a plug-in

You can also show your related posts without using a plug-in. If you using YARP plug-in then you are playing with your websites memory. This type of plugins is memory killer. They may slow down your website. Add this code on single.php file:

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
‘tag__in’ => $tag_ids,
‘post__not_in’ => array($post->ID),
‘showposts’=>5, // Number of related posts that will be shown.
‘caller_get_posts’=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo ‘<h3>Related Posts</h3><ul>’;
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php
}
echo ‘</ul>’;
}
}
?>

 

6. Display your adsense ads to search engines visitors only

This is possible to display adsense ads only for search engine traffic. There is no violation with Google adsense ad policy. Just add this code on functions.php file:

function scratch99_fromasearchengine(){
$ref = $_SERVER[‘HTTP_REFERER’];
$SE = array(‘/search?’, ‘images.google.’, ‘web.info.com’, ‘search.’, ‘del.icio.us/search’, ‘soso.com’, ‘/search/’, ‘.yahoo.’);
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}
$SE array specifying the search engines and you can add new search engine here. Then add the following code on your websites template where you want to display the ads. Then it will only seen by search engine visitors
if (function_exists(‘scratch99_fromasearchengine’)) {
if (scratch99_fromasearchengine()) {
INSERT YOUR CODE HERE
}
}

 

If you follow this tips and tricks, it will make your word press website more good-looking like a pro-longer. It will also increase reader’s experience. If your visitors stay a lot of time on your website then definitely your bounce rate will be decreased.

About the Author

Taposh kapuria is a well known tech blogger and founder of TalkAndTalkers. He likes to inspire people learning about internet technology.

Digiprove sealCopyright secured by Digiprove © 2014-2015 Vishal Sharma

About Taposh kapuria

Taposh kapuria is a well known tech blogger and founder of TalkAndTalkers. He likes to inspire people learning about internet technology.