Creating an admin meta box to save post as pending

The reason your code does not work is that the if-statement checking isset( $_POST[‘wp_cfc_save_meta_box’]) never evaluates to true. Your code generating the submit button, <?php submit_button( __( ‘Save as Pending’ ), ‘secondary button-large’, ‘Publish’, false ); ?> yields the following HTML: <input type=”submit” name=”Publish” id=”Publish” class=”button button-large” value=”Save as Pending” /> WordPress’ submit_button function takes … Read more

Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )

This is that classic question, do you have 6 eggs or half a dozen, and frankly, it doesn’t actually matter. It is however better to use get_comments_number() because the post object is retrieved from the $GLOBALS[‘post’] global which is set by the_post() inside the loop the post object is validated through WP_Post (through get_post()) the … Read more

Edit custom fields in posts list

Yes, you can use Admin Columns Pro (paid plugin with free version) to use inline edit for custom fields columns just from the WordPress posts list. It even comes with sorting and filtering for columns. You can easily add new columns with this plugin. https://www.admincolumns.com/ There are also plugins that allows you to bulk edit … Read more

How to display the requested post only?

WordPress creates the default query on each page automatically based on the requested URL. Your template file should contain the standard loop to output whatever the default query contains. if( have_posts() ){ while( have_posts() ){ the_post(); the_title(); the_content(); } }

Display value of custom field at the beginning of a post

You need to prepend value stored in _subtitle to the content of the post so that it works. Please place following code in your theme’s functions.php file and it shall work. Please let me know how it goes so that I may assist further: add_filter( ‘the_content’, ‘prepend_subtitle_to_content’ ); function prepend_subtitle_to_content( $content ){ $subtitle = get_post_meta( … Read more

Sticky Post from page 2 and on

Sticky posts are a pain in the butt, and is not properly implememnted IMHO. The source code clearly shows that sticky posts are only moved to the top on page one of the homepage (or any custom instance of WP_Query which emulates the homepage), sticky posts does not get removed from the paged pages. This, … Read more