Search Filter CPT, Custom Loop

You’ve used incorrect names for the hook. As documented here, the hook name should be wp_ajax_ followed by the action parameter that you’re sending in the request. In your example that’s data_fetch, so: add_action(‘wp_ajax_my_action’ , ‘data_fetch’); add_action(‘wp_ajax_nopriv_my_action’,’data_fetch’); Should be: add_action( ‘wp_ajax_data_fetch’, ‘data_fetch’ ); add_action( ‘wp_ajax_nopriv_data_fetch’, ‘data_fetch’ );

How to get_term_meta on single custom post?

You will need to use get_the_terms() to get the taxonomy terms associated with the post and loop through them until you find one that has an image set: $post. = get_queried_object(); $terms. = get_the_terms( $post, ‘taxonomy_name_here’ ); $image_url = null; if ( $terms && ! is_wp_error( $terms ) ) { foreach ( $terms as $term … Read more

Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin

Create custom actions with add_filter(post_action_{$action}); Even if it’s just to test, editing core files is bad practice. I prefer to download the source code onto my own machine and find where and how the hooks are firing. Anyway, there is very poor documentation in this part of the source code, but I’ve been studying it … Read more

How to rewrite the beginning and end of the permalink structure in a custom post type?

I recently wrote an answer to a similar question, so be sure to check it out because you can just use the same code, except you’d use the post type dvposts and not ex_article, and use the structure d/%dvposts%/%post_id%. But the trick there is quite simple: When you call register_post_type() with rewriting enabled, WordPress always … Read more

Set parent for custom post type archive rewrite url

First, you need to register the %office% rewrite tag: // First, add the rewrite tag. add_rewrite_tag( ‘%office%’, ‘([^/]+)’, ‘post_type=office_members&office_name=” ); // Then call add_permastruct(). add_permastruct( “office_members’, … ); Then, add the custom office_name arg to the public query vars so that WordPress reads/parses it from the URL: add_filter( ‘query_vars’, function ( $vars ) { $vars[] … Read more