Registering an optional custom post type from a plugin
Registering an optional custom post type from a plugin
Registering an optional custom post type from a plugin
Sorry I was using wrong structure, after looking through a bit more i found out exact difference for CPT and cutom taxonomies. For custom post types the template structure is like:-\ single-{post-type}.php archive-{post-type}.php search.php index.php And for Custom taxonomies, the template structure I found out from here:- Link:-Templates for Custom Post Types and Custom Taxonomies
By default get_post_meta() returns an array. Set the last parameter to true to return the value of the meta data. See the codex as a reference > Your code should be: $font_awesome_icon = get_post_meta(get_the_ID(), ‘font-awesome-icon’, true);
This part require(‘./wp-blog-header.php’); is all kinds of bad idea. And if your file is indeed in plugin folder then header isn’t even in that location. Custom loads of WordPress core are brittle and the technique is typically only justifiable for performance reasons. It would be better to structure your endpoint via creating actual rewrite endpoint, … Read more
I solved it: Just in case anybody ever has any trouble querying a post with the same term of a Taxonomy in another Post Type. I’ll post my answer below because I finally solved it on my own. <?php $terms = get_the_terms( $post->ID, ‘supplier-tax’); foreach ( $terms as $term ) { $termID[] = $term->term_id; } … Read more
As per the ACF documentation, you must pass either the term and term ID or the term object to the get_fields() function for a taxonomy. So in your case, you would replace $tag_image = get_field(‘tag_image’); with: $tag_image = get_field(‘tag_image’, $term);
index.php is not the template for the homepage, it’s the fallback template. Right now every page you load is falling back to the catch all index.php template, but your index.php doesn’t have a main loop, and isn’t set up as the fallback catch all template. Instead it’s doing its own new query and displaying the … Read more
You can use a function called add_post_type_support Hook into init after the post types have been created, and add support for comments. add_action(‘init’, ‘my_cpt_add_excerpt’, 100); function my_cpt_add_excerpt() { add_post_type_support(‘mycpt’, ‘excerpt’); } …where mycpt is the name of your custom post type. If you want to do it cleanly, you can always deregister the custom post … Read more
The syntax is not ‘post-type’ or ‘post-status’, it is with an underscore instead of a dash: ‘post_type’ => ‘testimonials’, ‘post_status’ => ‘publish’,
To display ‘news’, you’ll have to add it to your loop arguments: $wp_query->query( ‘post_type’ => ‘news’, ‘posts_per_page=”.get_option(“posts_per_page’).’&paged=’.$paged );