Which Template Page Should I Use?

you could always make a custom wp_query and put it in a template-custom.php. $the_query = new WP_Query( array( ‘post_type’ => ‘faqs’, ‘tax_query’ => array( array ( ‘taxonomy’ => ‘audiences’, ‘field’ => ‘slug’, ‘terms’ => ‘merchants’, ) ), ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); // Show Posts … the_title(); endwhile; /* Restore original Post … Read more

Main query not querying any posts in custom taxonomy template

I think the issue here is that when registering the post type, you’ve set exclude_from_search to true. See this note from the WordPress Coedex: Note: If you want to show the posts’s list that are associated to taxonomy’s terms, you must set exclude_from_search to false (ie : for call site_domaine/?taxonomy_slug=term_slug or site_domaine/taxonomy_slug/term_slug). If you set … Read more

Remove Quick edit for custom post type?

You can add a filter to the hook named post_row_actions. Here’s a sample code: (make sure to replace my-cpt with the actual post type name) add_filter( ‘post_row_actions’, ‘my_cpt_row_actions’, 10, 2 ); function my_cpt_row_actions( $actions, $post ) { if ( ‘my-cpt’ === $post->post_type ) { // Removes the “Quick Edit” action. unset( $actions[‘inline hide-if-no-js’] ); } … Read more

Getting 400 Bad Request on AJAX Call

I believe the problem is here: // handle AJAX calls for both logged in and guest users add_action(‘wp_action_websites_cpt_create_post’, [$this, ‘create_post’]); add_action(‘wp_action_nopriv_websites_cpt_create_post’, [$this, ‘create_post’]); Because the format should be: add_action( ‘wp_ajax_{ACTION_NAME}’, [ $this, ‘create_post’ ] ); add_action( ‘wp_ajax_nopriv_{ACTION_NAME}’, [ $this, ‘create_post’ ] ); ..where {ACTION_NAME} is the “action” name, e.g. websites_cpt_create_post. See wp_ajax_{$_REQUEST[‘action’]} and wp_ajax_nopriv_{$_REQUEST[‘action’]}.

Custom post type sorting: alphabetical order

Try using $query->get() instead of get_query_var(). function my_orderby_filter($orderby, &$query){ global $wpdb; //figure out whether you want to change the order if ($query->get(“post_type”) == “portfolio”) { return “$wpdb->posts.post_title ASC”; } return $orderby; } Alternatively, you can use this one, which filters the query via the pre_get_posts hook. add_action( ‘pre_get_posts’, ‘my_orderby_filter2’ ); function my_orderby_filter2( $query ) { … Read more

how to set a WP Plugin’s url

This is a perfect use case for WordPress’ REST API. It probably makes sense, to create a custom endpoint, where you can in detail define what results you need. Something along the lines of <?php add_action( ‘rest_api_init’, function () { register_rest_route( ‘kostas_calendar/v1’, ‘/feed/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘kostas_calendar_endpoint_feed’, ) ); } ); function … Read more