get comments for custom post type
get comments for custom post type
get comments for custom post type
To use page.php specifically, you can use the template_include filter. You could also copy page.php in your theme, saving it as single-foo.php, and it would then be used for your “foo” CPT’s individual posts. You would want to do this in a custom or child theme rather than editing a parent theme directly, so that … Read more
Post types are registered on every load. They’re not stored in the database or some other sort of persistent storage. The posts are, but not the post types. So the correct place to flush rewrite rules is when the theme is activated. This can be done with the after_switch_theme hook: add_action( ‘after_switch_theme’, ‘flush_rewrite_rules’ ); For … Read more
You’re trying to loop through the thumbnail, which doesn’t make any sense: foreach ($thumbnail as $thumb){ And then inside the loop you’re referring to $thumbnail again anyway: <img class=”thumbnail zoom” src=”https://wordpress.stackexchange.com/questions/280435/<?php echo $thumbnail[0];?>” > wp_get_attachment_image_src() returns an array that looks like this: array( 0 => ‘http://website.com/path/to/image.jpg’, // URL 1 => 150, // Width 2 => … Read more
You use the callback in a class context, but I see no class declaration. Maybe it was left out, but here’s a possible solution without using class. function rttk_create_boxes() { $myarray = $this->rttk_get_posttype_array(); foreach ( $myarray as $key => $value ) { add_meta_box( ‘rttk_’ . $key . ‘_id’, __( ‘Details’, ‘rara-theme-toolkit-pro’ ), ‘rttk_testimonials_metabox_callback’, null, ‘side’, … Read more
You will need to use this code: $the_query = new WP_Query( array( ‘post_type’ => ‘courses’, ‘tax_query’ => array( array ( ‘taxonomy’ => ‘courses_category’, ‘field’ => ‘slug’, ‘terms’ => ‘yourterm’ ) ), ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); // Show Posts … endwhile; You can convert this in shortcode and just append it on … Read more
You could get all posts/pages, check if the shortcode for your plugin is used, and if so retrieve the permalink for that post/page. Other than that, I don’t know of any reliable method. And while I think your intentions are good, this does not really belong in your plugin, it isn’t really your job to … Read more
Yes I did: I needed <?php if($post->post_type == ‘customposttype’ ){ ?> On the next line. Several sources I’ve seen omit that.
register a new post type and then change the post_type column of your existing entries in the posts table in the database.
You can use has_term() to check if a post is in a specific term. if ( has_term( ‘reel’, ‘filter’, $post->ID ) ) { get_template_part( ‘loop’, ‘work_feed_reel’ ); } else { get_template_part( ‘loop’, ‘work_feed’ ); }