WordPress saves page templates that is assigned to a specific page in the db in the wp_postmeta
table.
These are saved as follows:
'meta_key' => '_wp_page_template',
'meta_value' => 'NAME_ OF_TEMPLATE'
With this in mind, you can loop through pages which shares a specific page template, using get_pages
(You can also make use of WP_Query
)
Example:
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-special.php'
));
foreach($pages as $page){
echo $page->ID.'<br />';
echo apply_filters( 'the_content', $page->post_content );
}
Related Posts:
- Jquery Slider for profile template
- if ( is_home() && ! is_front_page() )
- Is including the loop necessary for page.php? [duplicate]
- What is best way passing variables to theme templates and using them different places like widgets?
- Page template not displaying
- How to get_template_part using AJAX?
- wp alchemy multiple image uploader output images to template
- code suddenly appearing from my tempate second loop
- Get search.php results in header.php?
- WordPress Loop inside Loop?
- Template structure
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Order archive results by post id in custom taxonomy template
- Default ‘post’ post type archive slug?
- How do I make a variable available inside partials?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- Second Loop Showing Only One Post on Single Post Page
- How do I put my frontpage featured image in a page template for home.php?
- Get markup for post without loading into the template
- How to render the single post template with the post name?
- excerpt not showing up
- new custom theme – posts displaying on top of one another
- How do i create a list-posts-page?
- How to sort a loop after most viewed
- How to loop specific Category menu from archive page?
- How do I set the Stewart Search Template to return only published posts in the result
- Is it possible to set archive.php instead of index.php to display blog?
- Using is_page_template inside loop
- is it bad to copy the loop for a template?
- Is “the loop” a template tag?
- Deeply Nested Menu Loop with Twig using Timber [closed]
- WordPress with woocommerce custom query
- Alternative layout the loop
- Cant pull in featured Image
- Template included with plugin doesn’t return all posts for custom taxonomy
- Creating a archive for taxonomy terms, not the term results
- Secondary loop cuts off at 10 posts?
- Need a conditional to test if title of parent page matches title of child page
- get all page templates
- Load featured article once in a loop
- wordpress showing all posts instead of date range
- How to implement template file and the loop
- Same posts within a paginated page
- How can I create an entirely new, separate display of posts?
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- add_filter() doesn’t work in loop
- Content/Excerpt length control for a specific loop?
- Why we use if with while loop?
- Loop posts only excluding first post
- Loop repeating design pattern
- Displaying the last page of posts
- How to get_posts where ‘menu_order’ is more than 0/zero?
- How to load all pages into one page with their templates
- How to return only one instance of each, from the entire loop
- Combining action and filter?
- Shortcode with a foreach and arguments
- Detect if current page is front page within custom query
- Sanitize Custom Field Value in Meta Query
- show random image in loop if image is not set
- need help looping add_action in wp
- Does WordPress Loop have a function like Shopify’s cycle?
- Combine the results of two loops [closed]
- How can I improve the performance of this query_posts loop?
- Add leading zero to current post display [closed]
- Output meta into arrays
- Moving wordpress to different url/server creates redirect loop
- Pulling in featured image into default recent posts widget
- Modify loop output for a specific list of categories
- Print the whole page?
- Pagination for two loops
- Loop info in jquery Tabs – loop into a variable?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- On click some element i want to use some template
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Insert content above an embedded video inside Wordress’ php the_content
- the loop printing post in one grid
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- WP update_post_meta link loop
- Load different template for CPT (in loop) in my plugin?
- query_posts ignores the argument
- Need some help with “the_widget()” function
- Exclude Authors based off date of last post
- Loop from another WP site onto mine
- Having issue with WordPress loop
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop