Change div background acording to the selected category

If you use wp_list_categories (see Codex), it automatically adds the classes cat-item,cat-item-{ID} and (to the current category being viewed) current-cat. (It also adds current-cat-parent to the parent of the current category). This should be enough to style any particular category a certain way, and style the current category a particlar way. However, you can obtain … Read more

is_page() or is_single not working

The problem is probably because wp_print_scripts is too late to deregister scripts as this is when they are outputted to the template. You should consider using wp_enqueue_scripts or wp_register_script instead. This question may help: wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused

Use a shortcode to display custom meta box contents

yeah, the question is a bit unclear. but i think you need shortcode attributes function get_custom_field_fn( $atts) { global $post; extract( shortcode_atts( array( ‘meta’ => ” ), $atts ) ); $custom_field_value = get_post_meta($post->ID, $meta, true); return $custom_field_value; } add_shortcode(‘cf_name’, ‘get_custom_field_fn’); see the codex: http://codex.wordpress.org/Shortcode_API#Attributes

Show Custom Message in WordPress Admin

add_action(‘admin_notices’, ‘my_custom_notice’); function my_custom_notice() { global $current_screen; if ( ‘my_post_type’ == $current_screen->post_type ) { echo “<h1>Whatever needs to be said</h1>”; } } Put this in your functions.php or plugin file. Replace ‘my_post_type’ with the name of your post type.

Infinite counting in WordPress

This looks like a custom function. It’s passing $count to a function called array_pick() to limit the size of your follower array. It also looks like array_pick() is a custom function. But you can easily stop the function from limiting your count by removing the call to array_pick(): function get_random_followers($userid, $count = 10){ $followers = … Read more

How to disable Edit Post and Allow only Custom Field?

You can remove post type support for the editor on a conditional basis. The following should work: add_action( ‘add_meta_boxes’, ‘wpse45113_remove_editor’ ); function wpse45113_remove_editor() { // change the capability and post type to whatever is appropriate if ( ! current_user_can( ‘install_plugins’ ) ) remove_post_type_support( ‘post’, ‘editor’ ); } I’m using add_meta_boxes because it fires not too … Read more

wordpress acts like functions.php doesn’t exist [closed]

When developing locally, always set the following in your wp-config.php to see all errors: // DEBUG error_reporting( E_ALL ); /** Php error log */ @ini_set( ‘log_errors’, ‘On’); @ini_set( ‘display_errors’, ‘On’); define( ‘WP_DEBUG’, true ); define( ‘SAVEQUERIES’, true ); // file: /core_root/content/debug.log define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, true );