create function to call category name and slug

You don’t need to hook the dw_get_category() function. Simply do it like this: function dw_get_category() { global $post; $categories = get_the_category($post->ID); if ( $categories ) { foreach ($categories as $category) { $dw_category_slug = $category->slug; $dw_category_name = $category->name; } } else { $dw_category_slug = ‘utopia’; } $dw_category = array(‘name’ => $dw_category_name, ‘slug’ => $dw_category_slug); return $dw_category; … Read more

I cannot include a file in my plugin settings page

Most likely the file cannot be found, I’m assuming the file you’re trying to include is located in your theme folder, in that case you should use: require_once( TEMPLATEPATH . ‘/file.php’); TEMPLATEPATH will return something like this: /home/user/httdocs/wp-content/themes/twentyeleven. Worst case scenario you’ll find a Fatal Error, but that’ll help to find the problem.

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