Display a specific post from a custom post type on static page
-
I am relatively new to wordpress and I am currently trying to create a multilingual site where the different languages are housed in separate subdirectories (i.e. https://www.site.com/en/pages). I am using CPT UI, Custom Post Type Templates, and Advanced Custom Field Plugins. Using CPT I have a custom post type ‘en’ for my english site, under this custom post type I have field groups that contain all of the content I need for each of the static english pages. Each field group represents a separate page. In other words, when I want to create a new page, I create a new ‘en’ CPT and simply fill in the fields for the specific page, leaving the rest blank. Then I use CPT templates to select the template for the page. So far everything works, except all of the posts with empty fields show as empty posts on the front page. In other words if I make a post service and fill in just the service field group fields and set the page template to services, then make an equipment post and fill in just the equipment field group fields, and set the CPT template to equipment, but this ‘equipment’ post shows up as a blank post on my services page. What I would like to do is simply filter specific posts for each page, so that blank posts don’t appear. my current code is as follows:
<?php $args = array( 'post_type' => 'en', 'posts_per_page' => '1', 'en_taxonomy' => 'service' ); ?> <?php $service = new WP_Query($args); ?> <?php while ($service->have_posts()) : $service->the_post(); ?>
- The topic ‘Display a specific post from a custom post type on static page’ is closed to new replies.