CPT Meta Searching

The code you found modifies the main query on pre_get_posts and unsets the search terms so WP_Query doesn’t run a real search query. What you want is // Filter the search SQL that is used in the WHERE clause of WP_Query. apply_filters_ref_array( ‘posts_search’, array( $search, &$this ) ); which runs previously in WP_Query::get_posts(). This later … Read more

How do I alter the position of a Custom Post Type menu item within my plugin admin menu?

As the dashboard uses the menu_position 2, just use menu_position 1. so: $args = array( ‘label’ => __( ‘programmes’, ‘hiblio’ ), ‘description’ => __( ‘Programmes for application from partner organisations’, ‘hiblio’ ), ‘labels’ => $labels, ‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘comments’, ‘revisions’, ‘custom-fields’, ), ‘taxonomies’ => array( ‘programmes_categories’ ), ‘hierarchical’ => true, … Read more

Conditional to modify query results

here is the mysql query you can use to get the result having distance less then your value. SELECT * , pm1.meta_value as latitude, pm2.meta_value as longitude , (((acos(sin(([latitude]*pi()/180)) * sin((pm1.meta_value * pi()/180)) + cos(([latitude]*pi()/180)) * cos((pm1.meta_value * pi()/180)) * cos((([longitude] – pm2.meta_value)* pi()/180))))*180/pi())*60*1.1515 ) as distance FROM wp_posts p JOIN wp_postmeta pm1 ON pm1.post_id … Read more

Custom Post Type and API REST is not working

Put this code in function.php add_action( ‘init’, ‘my_customer_cpt’ ); function my_customer_cpt() { $labels = array( ‘name’ => _x( ‘Customers’, ‘post type general name’, ‘your-plugin-textdomain’ ), ‘singular_name’ => _x( ‘Customer’, ‘post type singular name’, ‘your-plugin-textdomain’ ), ‘menu_name’ => _x( ‘Customers’, ‘admin menu’, ‘your-plugin-textdomain’ ), ‘name_admin_bar’ => _x( ‘Customer’, ‘add new on admin bar’, ‘your-plugin-textdomain’ ), ‘add_new’ … Read more