hide a certain custom field

This should do it. Tested locally and it works. // Hide ‘included’ and ‘not included’ custom meta fields // from the edit ‘excursion’ post type page. function my_exclude_custom_fields( $protected, $meta_key ) { if ( ‘excursion’ == get_post_type() ) { if ( in_array( $meta_key, array( ‘included’, ‘not included’ ) ) ) { return true; } } … Read more

Getting posts under the custom post type ui category

Worked perfectly for me!! Code will bring the posts(under CPT UI) to any page template. <?php $loop = new WP_Query( array( ‘post_type’ => ‘specialoffers’, ‘cat’ => ’12’, // Whatever the category ID is for your aerial category ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, // Purely optional – just for some ordering ‘order’ => ‘DESC’ // … Read more

Displaying the first category from a custom taxonomy with get_the_terms

Hello here is an example i have used : <?php while ( have_posts() ) : the_post(); $category = get_the_terms( $id, ‘event_category’ ); //get First Category $firstCategory = $category[0]; //get category link $category_link = get_category_link($firstCategory->term_id); //echo category name echo $firstCategory->name; endwhile; ?> change event_category with your taxonomy slug

How to have custom post type /example/ and then posts /example/posts.html

This is exactly how wordpress works. For each Custom Post type Create an archive-custom_post_type_name.php and a single-custom_post_type_name.php WordPress automatically loads that file when someone goes to the url. so if your custom posts types were koolio and notsokool then you would need these 4 files in your theme child (you’re using a child theme, right?!) … Read more

get_attached_media() on author page not working

I assume that you have a simple misunderstanding of what this function actually does and what it should be used for: get_attached_media() simply fetches all child posts for a given posts: if ( ! $post = get_post( $post ) ) return array(); $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => $type, ‘posts_per_page’ … Read more

Modify action buttons for custom post type

If you look here https://developer.wordpress.org/reference/hooks/post_row_actions/, the second argument for the post_row_actions filter is a post object, so you should be able to do : function remove_quick_edit($actions, $post) { $post_id = $post->ID; $post_type = $post->post_type; if($_GET[‘post_type’] == ‘form-enquiry’) { unset($actions[‘inline hide-if-no-js’]); } $actions[‘reply’] = ‘<a href=”#”>Reply</a>’; //return $actions; echo ‘<pre>’; print_r($actions); echo ‘</pre>’; } add_filter(‘post_row_actions’, ‘remove_quick_edit’, … Read more