Update status of all posts in a category

I am sure there’s an easier way to accomplish this, but this how I would’ve done. Query all posts with category X and status X Update query results with status Y. $target_category = ‘news’; $change_status_from = ‘draft’; $change_status_to = ‘publish’; $update_query = new WP_Query(array(‘post_status’=>$change_status_from, ‘category_name’=>$target_category, ‘posts_per_page’=>-1)); if($update_query->have_posts()){ while($update_query->have_posts()){ $update_query->the_post(); wp_update_post(array(‘ID’=>$post->ID, ‘post_status’=>$change_status_to)); } } You can … Read more

How to override menu markup?

OK got it. For anyone who needs to do this , it is best you extend Walker_Nav_Menu class if you just need to add things to existing wp menu structure. Otherwise if you are extending Walker class you kinda have to rebuild the menu completely. Include this class class Walker_Extend_Menu extends Walker_Nav_Menu { // Tell … Read more

Where are theme codes located for WordPress?

They’re probably referring to the functions file in your theme, functions.php. This file is loaded by WordPress during setup, and gives you an opportunity to do things or register hooks and filters. Note that this file is optional, and not every theme has a functions.php, if that’s the case just create one yourself Keep in … Read more

What does this mean in wordpress? Easy question

It’s the text domain, used for translation. When you run something like this: <?php _e( ‘Hello World’, ‘html5blank’ ) ?> …WordPress will attempt to find the translated string in the loaded MO file for HTML5 Blank: load_theme_textdomain( ‘html5blank’, ‘path/to/language.mo’ );

How to switch theme if the current user is admin?

You are sort of doing this in a roundabout way. WordPress has a function called switch_theme(): add_action( ‘setup_theme’, ‘switch_user_theme’ ); function switch_user_theme() { if ( current_user_can( ‘manage_options’ ) ) { switch_theme(‘twentytwelve’); } else { switch_theme(‘twentythirteen’); } } The argument is the directory of the theme you want. I can’t help but think this is a … Read more

WordPress root directory change + Theme directory change

You can move the installation and also plugin and content folder. The follow source demonstrate this. //* // Custom content directory define( ‘WP_CONTENT_DIR’, dirname( __FILE__ ) . ‘/wp-content’ ); define( ‘WP_CONTENT_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/wp-content’ ); // Custom plugin directory define( ‘WP_PLUGIN_DIR’, dirname( __FILE__ ) . ‘/wp-plugins’ ); define( ‘WP_PLUGIN_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . … Read more

How do I make the most minimal vanilla theme possible with nothing but raw content?

The most minimal theme possible has two files: style.css and index.php. style.css /* Theme Name: Bare-bones theme*/ index.php <?php if( have_posts() ) { while( have_posts() ) { the_post(); the_content(); } } I’m not sure you could make it more “vanilla” than that. Keep in mind that any HTML markup within the post’s content will still … Read more

Unable to set featured image

Try checking your Browsers Javascript console, Media Library in WordPress is heavily depended on javascript’s such as jQuery. also if your Javascript is broken due to concatenation, then add the below line in your wp-config.php file. define( ‘CONCATENATE_SCRIPTS’, false ); Or you can even try re-installing WordPress.