How to display number of page views on a post?

Try this Works on single site // post views function setAndViewPostViews($postID) { $count_key = ‘views’; $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); } return $count; /* so you can show it */ } You need to add the following function to your theme’s … Read more

Limit the amount of words displayed by the Latest News plugin, or recommend an alternative [closed]

If you go into your /wp-content/plugins directory, and edit the latest-news.php file, on line 85 change: <?php the_content(‘read more…’);?> … to: <?php the_excerpt(‘read more…’);?> Note that modifying plugins is risky, because if you do an automatic update of the plugin after this, your changes will be modified. Because of this, it is advisable to branch … Read more

How to include this jQuery File in wordpress?

You should be using wp_register_script() and wp_enqueue_script(), so, for example: add_action( ‘wp_enquque_scripts’, ‘my_script_enqueue’ ); function my_script_enqueue() { wp_enqueue_script( ‘my-jquery’, ‘URL TO THE FILE’, array( ‘jquery’ ) ); } Also, as mentioned by Zack, you should be registering your jQuery as such, as wordpress does not use $ for jQuery by default. jQuery( document ).ready( function( … Read more

Opening a link automatically on page load?

You can use JavaScript to trigger events upon page load. The example below uses jQuery. $(document).ready(function () { // Select a link by ID $(‘#specific-link’).trigger(‘click’); // Select the first link with a certain class $(‘a.thickbox’).first().trigger(‘click’); }); http://api.jquery.com/trigger/

do add_action on condition

Use has_category() to check if a post belongs to a certain category. function email_friends( $post_ID ) { if ( has_category( ‘uncategorized’, $post_ID ) { $friends=”[email protected], [email protected]”; wp_mail( $friends, “sally’s blog updated”, ‘I just put something on my blog: ‘ . get_permalink( $post_ID ) ); } } add_action(‘publish_post’, ’email_friends’); And you don’t need to return anything … Read more

WordPress : Explain Plugins & Theme string value in database

The value is a serialized php array. Further explanation is not really WordPress specific, but here you go — the ‘s’ is the length of the string representation of the succeeding array element (the length of the string in quotes). I.E. in a:2:{s:12:”twentyeleven”;s:7:”/themes”;s:9:”twentyten”;s:7:”/themes”;} the “12” in s:12 represents the length of twentyeleven.

Load Javascript from Plugin in One Page Only?

Drop this in your functions.php or a custom plugin. function wpse_57621_alo_tidy() { if ( $page_id = get_option( ‘alo_em_subsc_page’ ) ) { if ( ! is_page( $page_id ) ) remove_action( ‘wp_head’, ‘alo_em_ajax_js’ ); } } add_action( ‘wp’, ‘wpse_57621_alo_tidy’ ); It’s attached to the wp hook, which runs just after the request has been handled & queried. … Read more