Posts

Showing posts from July, 2020

Register Custom Post Type

To Register Custom Post // Register Post Type Agent function wppathfinder_custom_post_type() { register_post_type('agent', array( 'labels' => array( 'name' => __('Agents', 'pathfinder'), 'singular_name' => __('Agent', 'pathfinder'), ), 'public' => true, 'has_archive' => true, 'supports' => array('title','custom-fields','thumbnail','page-attributes',), ) ); } add_action('init', 'wppathfinder_custom_post_type');

ACF Custom Post Filtering Code

Use the Code to enable filitering option on custom post type: function my_pre_get_posts( $query ) { // do not modify queries in the admin if( is_admin() ) { return $query; } // only modify queries for 'event' post type if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'event' ) { // allow the url to alter the query if( isset($_GET['event_area']) ) {     $query->set('meta_key', 'event_area'); $query->set('meta_value', $_GET['event_area']);     } } // return return $query; }