I want to list Wordpress custom post types (notice/single-info.php) on a fixed page (notice list/archive-info.php).
I created a custom post type "Notice" from the Custom Post Type UI.
As a post type slug "info", I set "Archive" to "true" in the Custom Post Type UI settings.
I want to list the articles of the custom post type "Notice" on the fixed page (Notice list/archive-info.php), so
Information list <? php if (have_posts ()): // Conditional branch: If there are posts?> <? php while (have_posts ()): the_post ();// Start iterative processing?> <section> <ul> <li> <p><? php echo get_the_date ();?></p> "> <p><? php the_title ();?></p> </li> </ul> <? php endwhile;// End of iteration?> <? php else: // Conditional branch: If there is no post?> Post not found <? php endif;// Conditional branch end?> </section> </article> code
The loop is described in archive-info.php as above.
However, as shown in the image below, the posted article "Notice" single-info.php is not output in archive-info.php.
What is output is the fixed page title "Notice list/archive-info.php" of archive-info.php, and the link destination is also "Notice list/archive-info.php".
Where should I check or modify to list the custom post type (notice/single-info.php) on the fixed page (notice list/archive-info.php)?
Answer # 1
Information list <? php $the_query = new WP_Query (array ('post_type' =>'info'));?> <? php if ($the_query->have_posts ()): // Conditional branch: If there are posts?> <? php while ($the_query->have_posts ()): $the_query->the_post ();// Start iterative processing?> <? php // (omitted)?> <? php endwhile;// End of iteration?> <? php wp_reset_postdata ();?> <? php else: // Conditional branch: If there is no post?> Post not found <? php endif;// Conditional branch end?> </section> </article>
Is it like this?
Please add the option of WP_Query as appropriate.
Reference Function Reference/WP Query
- wordpress - i want to output custom post types by category
- php - custom post page in wordpress oh, can i have a fixed page as a parent?
- php - [wordpress] i want to use fixed pages to layer categories
- i want to be able to narrow down and search the value of a wordpress custom field
- php - fadetoggle does not work with custom js on wordpress and mobile menu does not close
- wordpress - advanced custom fields pro want to change the style of repeating fields
- php - can't post a custom wordpress post correctly in some environments? want to solve
- wordpress - i want to display a custom post type in the specified number
- wordpress - the second and subsequent pages of the custom post archive are all the same as the first page
- wordpress - questions about wp custom fields search
- wordpress - how to display advanced custom fields subfield images?
- php - wordpress fixed page image display
- php - to use custom fields in the wordpress theme "customizr"
- about displaying fixed pages in wordpress twentyseventeen and frontpagephp
- the line breaks entered in the text area of the custom field on the wordpress edit screen are automatically deleted one by one
- php - accordion does not work properly on fixed page of wordpress
- wordpress - i want to specify the save destination of the custom field file
- wordpress - wp multisite custom field naming
- wordpress - is there a way to delete the "custom post type" under the post in the wp administration screen?
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory