Custom Post Type Taxonomy Term Order by Title

After about 100 different tries, I got it to work. Not sure if there is a better way, but it works. $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName ); $args = array( ‘post_type’ => ‘clients’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’=>array( array( … Read more

unapprove comments on custom post type

You should be able to write a function that fetches all comments by comment type using get_comments(), then loop through them and set status using wp_set_comment_status(). e.g. Retrieve all comments associated with posts in the debate post type: $debate_comments = get_comments( array( ‘post_type’ => ‘debate’, ‘status’ => ‘approve’ ) ); Loop through each one, and … Read more

Getting titles from an array of IDs

You can make use of ids in $actor the following way to get the actor’s title. $args = array( ‘post_type’ => ‘actors’, ‘post__in’ => $actors, ); $actors_posts = new WP_Query( $args ); if( $actors_posts->have_posts() ) : while( $actors_posts->have_posts() ) : $actors_posts->the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; else: ?> echo ‘Oops, there are no posts.’; … Read more

custom comment fields on CPT

Non-CPT Comments Regarding the first issue: you’re not returning anything if your conditional is false. To simplify your code: function debate_comment_fields( $fields ) { // If conditional is true if( is_singular( ‘debate’ ) ) { // Do some stuff to $fields // Return $fields return $fields; } // If conditional is not true? } add_filter(‘comment_form_default_fields’,’debate_comment_fields’); … Read more

How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop

Retrieval of multiple posts in WordPress is almost always handled by WP_Query class (or get_posts() function that wraps it). There is quite a lot of documentation and information to it, but to narrowing it down to your specific case you will need to: set up posts loop for each term pass as arguments to each … Read more

Custom Post Type Root Template

There are a couple of solutions: Create archive-vendors.php, that displays whatever output you want (including static content or a secondary query, for example), and omitting the default loop (CPT archive index query). Set has_archive to false in your register_post_type() call, then create a static page named Vendors, that you can use to display whatever content … Read more