before start your posts loop in a custom page template you need to get posts from database by using wp_query()
or get_posts()
do some thing like this.
$args = array(
'posts_per_page' => 3
);
$my_query = new WP_Query($args);
// now start your loop
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post();
// print post data, title, content .etc
}
}
Related Posts:
- posts page – different lengths of excerpt
- loop not displaying posts on custom template page
- How do I stop the loop from repeating in my category template?
- Use special template for the first post in the loop
- Redirecting posts in WordPress to a specific page
- Should we trust the post globals?
- How to get posts published between a date and today?
- Get first post from wp_query
- Why do I need to use The Loop on pages (inside page.php etc)?
- Count singular post views automatically
- Looping through posts per category gives same posts for each category
- Display All Sticky Post Before Regular Post
- Accessing $post variable from template part
- How to have different content in the loop and single
- Specific loop in Shortcode
- how to show all post in my page-grid.php template page
- Repost post on specific date every year
- Search widget breaks when using multiple loops?
- Display Latest Post from all Categories
- Is it possible to have two different previews of a post (ie. two templates for one post)?
- custom wordpress post loop – hide iframe content
- Divide Loop Into Days & Categories
- Different template for posts of all subcategories of category
- Custom Post Templates
- Contact form 7 post loop [closed]
- How to display different number of posts
- How to filter posts that belong to a specific category only if that is the only category
- WP Query – duplicated posts once including tags in search results
- Most recent post from another database
- wp_tag_cloud() and the_taxonomies() work but not the_tag()
- What part of template to edit to remove category name from the top of posts?
- Show all posts in sidebar in single.php
- Split WordPress Latest Posts in Multiple Columns and Rows with one single loop [closed]
- Avoid duplicate post from same Taxonomy
- Alternate row and columns every X posts
- page.php showing loop of posts and not page content
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- How do I restart my loop with get_next_post()?
- Setting posts_per_page for taxonomy term template
- Posts will not display on page-mypage.php
- Pagination with an array of post objects?
- How to create new post content templates for my users?
- wp_query random post
- How many posts does the loop return?
- Display Posts on Custom Page
- Possible to alternate between two loops
- Multiple Loops Breaking Pages
- posts not showing on index.php
- Second get_permalink inside loop points to wrong URL
- Use Click Image to Play Youtube Video in a WordPress Loop
- The_excerpt() doesn’t parse – how to change that?
- Trying to edit archive.php to only show post extract, with featured image
- How to only publish posts with image in it
- Why won’t pagination work?
- Create a custom posts page
- Extracting relevant tags associated with that particular single post only
- Force a specific template as default
- Show posts by quarter
- Optimizing the blog loop
- Accessing Post ID Within Loop
- Different number of posts per row in grid layout
- linking to post outside the loop
- Cant’ Grab WordPress Built-in Posts Through Loop
- Trying to query all posts in category 4
- Pagination for normal (standard) posts on a page with a custom loop?
- Output Buffer Issue with Single Post View
- Defining ‘last’ class on foreach blog posts
- Prevent 404 of Author pages without posts
- How to save template data into wp_post table (post_content column)
- Want to change the post every three days with in specific category
- Current post categories and subcatecories outside of the loop
- Why does my “Add New Post” page have an old post in it?
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- “read more” redirects to the wrong page
- Count singular post views automatically
- How can I get the last post while on the first post for pagination? As if it were infinite
- Loop and output 4 rows of posts on home page
- Loop through all posts showing duplicates
- List Authors For Current Category
- Display the latest post from some selected authors
- Advanced Post Display/Pagination/Ordering
- Keep post format class with isotope filter
- How to use extract shortcode in loop?
- How to arrange different post categories in template
- Make assigning post to a specific category equivalent to assigning it to all categories
- How can I change the look of a post as is displayed
- Displaying posts on Homepage
- Where are my posts linked to? I keep getting a Not Found Error, and I have no single.php page
- Sort by category and then date?
- Loop not allowing infinite scroll after post per page limit
- Customise the appearance of 4 specific post ID’s within the loop?
- what template-part to call, to have my post in the center of the page?
- Creating / Editing a post from within site template
- WordPress posts loop pagination – first page return 125 posts instead of 10 and the rest return 10
- The post order is different for logged-in and non-logged-in users? [closed]
- How do I show the post title if an advanced custom field hasn’t been used?
- WordPress “Posts Page” isn’t showing template dropdown
- Custom post order returning posts from other categories
- CSS code for “inserting a custom post divider” after each post
- How can I locate the single buddypress forum post template? [closed]