Custom WordPress Theme Development (2022) #25 - Displaying custom plugin posts with custom posts.

Опубликовано: 13 Март 2026
на канале: AGWS | And Go Web Solutions
103
4

How to make your own custom plugin from scratch using a pure PHP function and word press built in functions utilizing register_post_type();
//register_post_type( string $post_type, array|string $args = array() )

Steps
1. create a new file display code for single-courses_post.php , in case you want a different page to display your custom post type instead the normal single.php

2.create another file inside your ./inc (the included folder) and call it for example courses-catalog-display.php

3.add the comment for the template name
for example
/*Template Name: Courses Catalog Andgoedu */

4. Display the custom post types in 4 steps .
4.1. use the defined the $args variable by word press , and just mention the custom post type
4.2 Define a new variable for the custom post type
4.3 while loop over the new variable with the custom post type and add have posts and iterate it to the_post();
// Note make sure to add the code you want to loop over check the example in the git commit
4.4 end the while loop and reset the post data

check the git commit for the example done in this video

GIT Commit : https://github.com/andgo-edu/bootstra...

Useful links

1. Single page Template hierarchy :
Link: https://developer.wordpress.org/theme...

2. The loop
https://codex.wordpress.org/The_Loop

2. have_posts()
Determines whether current WordPress query has posts to loop over.
https://developer.wordpress.org/refer...

3. the_post()
Iterate the post index in the loop.
https://developer.wordpress.org/refer...