check_admin_referer not working in custom meta box for custom post type

Now in saving function … in which hook ? if you do this in “save_post_CPT”, it doesn’t work because this hook is called a first time a the object creation then you have to do this : add_action(“save_post_CPT”, function ($object_ID, \WP_Post $object, $update) { if (!$update) { // new object, here you can define default … Read more

get wordpress post loop by meta box date

Have you tried passing in the $args variable to query_posts, rather than $guide? query_posts($args); Also, you should be looking to create the custom query using WP_Query class and not the query_posts. See this answer for more details (https://wordpress.stackexchange.com/a/1755) Try the below code: $args = array(‘post_type’ => ‘post’, ‘meta_key’ => ‘meta_date’, ‘meta_value_num’ => , ); $my_query … Read more

Spit out list of distinct instances of custom field?

Here’s a dashboard widget you could manage them with: // add dashboard widget add_action(‘wp_dashboard_setup’, ‘wpse_dashboard_widget’); function wpse_dashboard_widget() { // only show widget to users who can publish pages if(current_user_can(‘publish_pages’)) { wp_add_dashboard_widget(‘deduped_dash_widget’, ‘Publications’, ‘wpse_create_deduped_dash_widget’); } } // widget contents function wpse_create_deduped_dash_widget() { // select publications without duplicates by using DISTINCT global $wpdb; $mentions = $wpdb->get_results(“SELECT DISTINCT … Read more

Getting a value from a custom field from a page that shares a parent with the current page

I’m assuming there are only two children in such cases. <?php $child_id = $post->ID; if ( $post->post_parent ) { $args = array( ‘post_parent’ => $post->post_parent, ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); $children = get_children($args); if(count($children) == 2) { $child_id = $children[0]->ID == $post->ID ? $children[1]->ID : $children[0]->ID; } } if ( … Read more