15 WordPress features (plugin free) will work for New Comers

2424

[If you want to add any feature in your site, then keep backup file of themes of site]

WordPress Short Feature:

15 WordPress feature, definitely work for New Comers.

wordpress-cogs

#1. Visitor Count Systems/ Feature:

Generally, many people use Post-Views plugin to know how many visitors have read our post, there are some small work for which it is better not to use the plugin.

For this, today we will do WordPress blog / system of counting post view of the site, writing some code line.

Steps: At first go to wp-admin option and then go to appearance menu and then go to editor option and then go to

functions.php

From template files.

Select that file.

Now write this code in below.

	function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}

[Remember, you will write surely after <?php and before ?> 

Step2: Now open

single.php

From the template file and write code in below.

1	<?php setPostViews(get_the_ID()); ?>

Step3: Now you want to show post view counter in which location, write code in below there.

1	<?php echo getPostViews(get_the_ID()); ?>

[Generally, many people use post beside title, date so, you have to set surely in

single.php

]

#2. In which way you will give permission to upload photo of WordPress blog/contributors of site.

At first, open

functions.php

Of themes in any editor.

Notepad/notepad++ or WordPress are in the dashboard.

Write code in below.

<?php
//allow contributor to add photos
if ( current_user_can('contributor') && !current_user_can('upload_files') ) {
    add_action('admin_init', 'allow_contributor_uploads');
    function allow_contributor_uploads() {
        $contributor = get_role('contributor');
    $contributor->add_cap('upload_files');
    }
}
?>

If you set this code at the starting point of

functions.php

You can do this.

#3. Write code in below in any place of themes if Facebook wants to show number of pan in anywhere on your blog, like header, footer or with each post or in single.php.

<?php
    $page_id = "YOUR PAGE-ID";
    $xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
    $fans = $xml->page->fan_count;
    echo $fans;
?>

#4. Display Google Search Terms:

google-search

Suppose someone search in Google by some writing and getting your link that person has come to your site, you will give to keep in his mind that visitor if you want, and that person has gotten your site of what writing he search, for those that visitor will keep in their mind your site’s keyword easily.

Write code in below from where you want to show search terms message.

<?php
$refer = $_SERVER["HTTP_REFERER"];
if (strpos($refer, "google")) {
    $refer_string = parse_url($refer, PHP_URL_QUERY);
    parse_str($refer_string, $vars);
    $search_terms = $vars['q'];
    echo 'Welcome Google visitor! You searched for the following terms to get here: ';
    echo $search_terms;
};
?>

[You can show my advice/message in the footer of your site.]

#5. Inform tuner automatically for publishing post I have a blog and many people post in that blog, and all posts have in your moderation, so if you follow that system in below when you will publish their posts then they will get to know by their emails.

Step: Write code in below in function.php file of themes like before.

function wpr_authorNotification($post_id) {
   $post = get_post($post_id);
   $author = get_userdata($post->post_author);
 
   $message = "
      Hi ".$author->display_name.",
      Your post, ".$post->post_title." has just been published. Well done!
   ";
   wp_mail($author->user_email, "Your article is online", $message);
}
add_action('publish_post', 'wpr_authorNotification');

[You have to write code surely upper of?>]

#6. Limit Post Revision:

When we edit some posts more times than a post is revisions for each time, which is not good for the database, so limit revision, though it will not destroy of the post.

Write code in below in

wp-config.php

File.

?php
# Maximum 5 revisions #
define('WP_POST_REVISIONS', 5);
# Disable revisions #
define('WP_POST_REVISIONS', false);
?>

[

wp-config

Is a core file of your WordPress, which is not a part of themes.]

#7. Make built in widget in the WordPress dashboard:

When we log in into any site, then it comes by a redirect, and there shows “Right Now”.

You will set message as you wish if you want, like you, will set policy of the site/blog in the dashboard.

Where it will support html, php, text.

Write code in below of themes like before.

functions.php
<?php function your_dashboard_widget() { ?>
<h3></h3> 
<h3>you are welcome for log in</h3>
<p> html,php </p>
<p>Enter here the message by Admin, here it will support html,php.
<?php };
function add_your_dashboard_widget() {
  wp_add_dashboard_widget( 'your_dashboard_widget', __, 'your_dashboard_widget' );
}
add_action('wp_dashboard_setup', 'add_your_dashboard_widget' );
?>

#8. Change the writing “Howdy” admin of WordPress dashboard:

Write code in below in

functions.php

Of themes.

<?php
// replace WordPress Howdy in WordPress 3.3
function replace_howdy( $wp_admin_bar ) {
    $my_account=$wp_admin_bar->get_node('my-account');
    $newtitle = str_replace( 'Howdy,', $my_account->title );
    $wp_admin_bar->add_node( array(
        'id' => 'my-account',
        'title' => $newtitle,
    ) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );
?>

[Here “log in” means a new title, you can change if you wish.]

#9. From many days we can’t log in dynamic copyright on our site, when New Year comes then copyright year will change automatically in the footers of site if you install dynamic copyright system, then you will not be changed year/date per year. Write code in below in theme’s footer, php (footer.php) file.

<b>(c) <?php echo date('Y'); ?></b>
| <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a>
| <?php bloginfo('description'); ?>

#1. The Custom feed footer is when someone reads writing through the feed of your site, then you can set some message in the footer of feed if you wish, write code in below in dit.php of theme’s function.

<?php
if ( !function_exists('custom_feed_footer') )
{
    function custom_feed_footer($content)
    {
        if(is_feed())
        $content .= ';(what you want to write)
        return $content;
    }
    add_filter('the_excerpt_rss', 'custom_feed_footer');
    add_filter('the_content', 'custom_feed_footer');
}
?>

#11. How you will impress and surprise visitors? Now come we honour users for all brand computers, if someone uses Mack then I will tell him thanks for using it and if someone uses windows then I will tell him also thanks. Write code in header or footer of themes.

<?php
if (stristr($_SERVER['HTTP_USER_AGENT'],"mac")) {
    echo 'Hello, Im a Mac User.';
} else {
    echo 'Thank you for useing PC';
}
?>

#12. (Time ago) This post has been written some time ago, write code in single .php of themes like twitter, where you want to show you will sit there.

<?php
# For posts & pages #
echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
#  #
echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago'; 
 
// Change to the date after a certain time
$time_difference = current_time('timestamp') - get_the_time('U');
if($time_difference < 86400) {
    //here goes the code from one of the sample above
} else {
    the_time();
};
?>

#13. Getting your link from twitter if someone comes to read posts in your blog, then welcome him also. Write code wherever of themes you want.

<?php
if (strpos($_SERVER[HTTP_REFERER], "twitter.com") == true) {
    echo "";(Thanks for visiting from twitter)
}
?>

#14. Write as you want in WordPress footer, generally, which has been written in the new version, Thank you for creating with WordPress, you can change it very easily if you want, write code in below in the function.php file of themes.

<?php
function remove_footer_admin () {
  echo '. (write here).Thank you <a href="http://wordpress.org">Wordpress</a> for giving me this filter.';
}
add_filter('admin_footer_text', 'remove_footer_admin');
?>

#15. Keep away posting of any of the text from the home page, write code as you wish

function.php

File of themes.

<?php
function excludeCat($query) {
  if ( $query->is_home ) {
    $query->set('cat', '-3,-5,-23');
  }
  return $query;
}
add_filter('pre_get_posts', 'excludeCat');
?>

Which ID has minus before, that’s post will not come on the first page, here

3
5

And

23

Are category ID. [Anybody will not paste by copying it, please write code in your own hand by seeing it]. Today I can’t give more, I will inform about the WordPress functional system in other day. And those who read English very well, they read regularly web design and development related articles by visiting our English blog.

What’s your Reaction?
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0