Override widget in function WordPress

You are getting this error because your class ass no method named widget which is a must to properly use the widgets api. Meaning that each class/widget that extends the WP_Widget class must have a method named widget which is responsible for the actual widget display. So consider this structure as a widget class skeleton: … Read more

Dynamic sidebar based on category

There are many solutions to your problem, I guess. Two solutions I would recommend are: 1. Register multiple sidebars. Register more sidebars and then include them conditionally in page templates. So if you need different sidebar for each category (let’s say you have 2 categories), then register 2 more sidebars (sidebar-cat-1, sidebar-cat-2) and then replace … Read more

Ajax load more button in Recent posts widget

Look at WordPress’s documentation on AJAX In your theme or plugin, you’ll want to have code like: add_action(‘wp_ajax_my_load_recent’, ‘my_load_recent_posts’); add_action(‘wp_ajax_nopriv_my_load_recent’, ‘my_load_recent_posts’); function my_load_recent_posts() { $args = array( /* Arguments go here, i.e. how many posts to get */ ); query_posts($args); /* [1] */ /* Header wrap output */ if (have_posts()) : while (have_posts()) : the_post(); … Read more

Most commented last 24h, week, month, year and all time – posts_where

Where? The WP_Comment_Query class has the following filter for its clauses: $pieces = array( ‘fields’, ‘join’, ‘where’, ‘orderby’, ‘order’, ‘limits’, ‘groupby’ ); $clauses = apply_filters_ref_array( ‘comments_clauses’, array( compact( $pieces ), &$this ) ); That means you can hook into comments_clauses and filter the $clauses[‘where’] part. How? Since WP 3.7, we got a WP_Date_Query class. It … Read more

Dashboard Widgets – Add Admin Page With Same Functionality

I guess “easy” is a relative term. Yes, you can create your own. For adding an admin page there are a glut of tutorials out there. This one works (and has some other info you might need) http://wp.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/. Search for “Add Your Own Settings Page or Admin Menu” on the page. jQuery UI is loaded … Read more

Debug errors on sidebar

You should check that the variable exists before using it. isset() will return true if a variable has been set and is not null. For example: update_post_meta($post->ID, “_sidebar”, $_POST[“link”]); will become: if ( isset( $_POST[“link”] ) ) { update_post_meta( $post->ID, “_sidebar”, $_POST[“link”] ); } As an aside, it’s a good idea to validate your data … Read more