Widget internal hooks and functions

Take a look at the default-widgets.php and widgets.php files from wp-includes folder. You’ll find a couple of filters and actions there which will help you. You’re gonna have to try them out, they aren’t documented. Create a list in array, preferrably of all widgetized areas and their id. – Use the filter sidebar_widgets, it will … Read more

disable defaault wordpress comments from a plugin

Most themes used comments_template to include their comment areas. It’s completely full of filters, one of which is the include file (usually comments.php) that you can hijack to include a file from your plugin that contains all the stuff for facebook comments (or nothing if you just want to disable comments. Example: <?php add_filter( ‘comments_template’, … Read more

Why doesn’t update_post_meta work for certain strings?

Check closely on your line: With the $path = $upload[‘file’] call I get that $path contains “C:\xampp\htdocs\wordpress/wp-content/uploads/2011/12/ReSharper-6.1-License18.txt” ‘\’ changes to “https://wordpress.stackexchange.com/” just after the ‘wordpress’ i.e. \wordpress/, hence invalidating your path. But when you use a hard coded path (which is not invalid), you get the answer. Try fixing your path first.

Setting post_id for single.php based on URL without a redirect

I figured it out, here is the solution for anyone else wondering how to do something like this: function force_ID($query) { global $wpdb; if (substr($_SERVER[‘REQUEST_URI’],-5) == ‘.html’) { $post_id = $wpdb->get_var($wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE post_name=%s AND post_status=”publish””,substr(basename($_SERVER[‘REQUEST_URI’]),0,-5))); if ($post_id > 0) $query->set(‘page_id’,$post_id); } } add_action(‘pre_get_posts’,’force_ID’); In examining the wp-includes/query.php file, I noticed that the … Read more

Plugin access to average users not only admin

The rules for themes and plugins are basically the same. You can make plugins and themes administrable by anyone in most respects except that non-admins can’t install and uninstall plugins/themes. For instance, you should use the if_current_user_can(‘do_stuff’) conditional to handle permissions on operations. Also, the add_menu_page() function lets you specify what capabilities a user needs … Read more

Setting a post’s category

Try doing this: $insert_post = wp_insert_post(array( ‘post_author’=>1, ‘post_date’=>date(‘Y-m-d H:i:s’), ‘post_date_gmt’=>date(‘Y-m-d H:i:s’), ‘post_content’=>”, ‘post_title’=>”, ‘post_excerpt’=>”, ‘post_status’=>’publish’, ‘comment_status’=>’closed’, ‘post_name’=>”, ‘post_parent’=>0, ‘post_type’=>’portfolio’, // with ‘portfolio’ custom post type ‘post_category’=>array($id), )); if( $insert_post ) { wp_set_object_terms( $insert_post, intval( $id ), ‘galleries’); } Using wp_set_object_terms you can set the terms for the post in any taxonomy. The first argument is … Read more