singular_name label in custom post type

The answer at that link is incorrect. The “Edit Animals” text from their answer uses the edit_item label, not singular_name. There’s a much longer list of labels that you’ll need to provide when registering a post type than just those two. The full list is kept here. As for singular_name, as far as I can … Read more

Custom REST endpoint not working to retrieve single posts (“rest_no_route”)

To get your expected result, you have to create a second endpoint. Your endpoint doesn’t know what to do with the last part of the path (the ID). register_rest_route(‘mytheme/v1/’, ‘my_cpt/(?P<id>[\d]+)’, array( ‘methods’ => WP_REST_SERVER::READABLE, ‘callback’ => ‘my_cpt_single_result’, )); Your CB function could be like this: function my_cpt_single_result( $data ) { $cpt_id = $data[‘id’]; // make … Read more

Route subpage to Custom Post Type

I usually struggle with this, however this time I managed it relatively easy. Main reference for this answer is here: https://codex.wordpress.org/Rewrite_API/add_rewrite_rule I’d like to use anything in the below as discipline. /artists/djave_co/anything First of all, I added a “rewrite tag” function custom_rewrite_tag() { add_rewrite_tag(‘%discipline%’, ‘([^&]+)’); } add_action(‘init’, ‘custom_rewrite_tag’, 10, 0); Next, I did print_r($wp_query->query_vars) on … Read more

Pagination doesnt work in custom post type

Taxonomy archive templates should not require a custom WP_Query. WordPress automatically queries the correct posts. Just use the main loop, without $loop->. You had already been doing this but commented it out for some reason. <?php get_header(); ?> <main role=”main”> <!– section –> <?php get_template_part( ‘breadcrumb’ );?> <!– Inner Pages Main Section –> <section class=”ulockd-service-details”> … Read more

Getting post attchment URL to populate a CPT Admin Page Column

The File field’s documentation has some options you can try, but here’s an example if your field’s Return Value is array, where you can use $gradingForm[‘url’] to get the attachment URL: $gradingForm = get_field( ‘grading_form’, $post_id ); echo $gradingForm ? ‘<a href=”‘ . esc_url( $gradingForm[‘url’] ) . ‘”>Grading Form</a>’ : ‘N/A’; And the proper way … Read more

ajax response not recieving

As per jQuery documentation, dataType: ‘json’ is supported. That is the thing that is being returned and parsed by jQuery to your success function. There is more information needed to resolve your issue. Does pin_shop.ajax_url properly resolve to //site.com/wp-admin/admin-ajax.php? If not, there’s your first problem. (To check this, console.log(ajax_url); just before your $.ajax call. I … Read more