Add few specific post ids to wp_query

Here is another way of doing it, specially if you need to work with the query object. The issue with merging queries is that you loose the correctness of the query object. My idea here is to run two separate queries, one very lean one to get post ID’s from the date_query query and then … Read more

Change Post Title Edit Box

You can add following code to your functions.php in the Theme-folder. Change the Custom Post Type(movie) name and the title to your wishes. function wpse213979_new_title_text( $title, $post ){ if ( ‘movie’ == $post->post_type ) { // Movie is the cpt name $title=”Enter movie name”; // The text you want to be shown } return $title; … Read more

How to change bulk post status

Yes, it’s possible to loop all publish posts and change their post status to draft. add_action(‘admin_init’,’wpse_244394′); function wpse_244394(){ $args = array(‘post_type’=> ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’=>-1 ); $published_posts = get_posts($args); foreach($published_posts as $post_to_draft){ $query = array( ‘ID’ => $post_to_draft->ID, ‘post_status’ => ‘draft’, ); wp_update_post( $query, true ); } }

Creating new page with pre-defined parent page

You are right on the mark with GET, that would probably be easiest to make use of. Try this: Add_Child_Page::on_load(); class Add_Child_Page { static function on_load() { add_action( ‘init’, array( __CLASS__, ‘init’ ) ); add_action( ‘admin_init’, array( __CLASS__, ‘admin_init’ ) ); } static function init() { add_action( ‘admin_bar_menu’, array( __CLASS__, ‘admin_bar_menu’ ), 90 ); } … Read more

Get the post_id of a new post

Try this… add_action(‘post_updated’, ‘myfunction’); function myfunction( $post_id ) { global $post; if (!file_exists(“/www/foo/blog/wp-content/uploads/” . $post_id)) { mkdir(“/www/foo/blog/wp-content/uploads/” . $post_id, 0777); } } NOTE: Change from save_posts to post_updated which will stop the duplicate issue as it fires on “publish” only and not every time you hit add new or update etc. NOTE: I verified this … Read more