Assign a template to a custom post type when displayed by the main loop on the home page

You are checking the source code of TwentySeventeen’s content.php selectively. The lines you quote are only about printing the publication time in case of a regular post. Directly below your lines the post/page title is printed regardless of post type. Regarding a) you don’t need to force anything, because as long as there is no … Read more

Sum a custom field that has a shortcode in it

Without your code it’s a bit difficult, so bear with me. Can you do this: $x=0; $x=do_shortcode (‘[your_shortcode]’); // say its 10 $valuetoadd = 20; //for example $exams_count_sum= $x + $valuetoadd; echo $exams_count_sum; //should equal 30 Or, if you are in a loop, this could be a good starting point: $examtotal=0; $examtotal_sum=0; while ( $the_query->have_posts() … Read more

Custom posttype content metabox

I think you may be in a recursive loop. if you hooked into save_post that will be triggered again when you call wp_update_post. you can temporarily remove the hook. Not knowing exactly how you have written the hook the below code is a guess. remove_action( ‘save_post’, [ $this, ‘saveModel’] ); wp_update_post([ ‘ID’ => $postId, ‘post_content’ … Read more

Create a simple Testimonial page

I would suggest a custom post type for your Testimonials. Each will be created as an individual post and you will have the ability to query, sort, categorize, your testimonials just as you can with blog posts, or any other post type. Non-technical site admins can simply “add new testimonial” and edit existing, etc, just … Read more

How to get Custom Post Type with Categories wise in WordPress using wp_query

Your question is very unclear (given that you don’t actually ask a question), but there are 2 problems with your code, both of which are corrected below: $args = array ( //’post_type’ => ‘article’, ‘posts_per_page’ => 5, ‘category_name’ => ‘starter’, // changed from ‘category’ to ‘category_name’ ‘meta_query’ => array ( array ( ‘key’ => ‘recommended_article’, … Read more

Custom Post Type (CustomPress) [closed]

I figured it out in the end from a combination of trial and error from a few different sources. Here is what I came up with in the end: <?php $key_1_value = get_post_meta( get_the_ID(), ‘_ct_datepicker_58d1755e1a654’, true ); if ( ! empty( $key_1_value ) ) { echo ‘<div class=”mtt date-added”>’ . ‘<span>’ . ‘Date Added:’ . … Read more

Custom Post Type posts not showing in category

Add post_type to first $args <?php $args = array ( ‘cat’ => 3, ‘post_type’ => ‘tv’, ‘posts_per_page’ => 3 ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?>