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
- Print Current Post Index number within Loop
- Should we trust the post globals?
- How to get posts published between a date and today?
- How set featured posts using checkbox in post edit screen?
- Post/Page Preview Template
- Get first post from wp_query
- Do we still need to include a “if (have_posts())” in templates?
- WP_Query: Why is sticky post not first item in loop?
- Query *only* sticky posts
- How to get Images included in Post
- Display all posts from specific categories on a page
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- Skip post in loop and mixin later
- How to show list of posts by author and category?
- Override the default number of posts to show for a single loop?
- get comments and get posts in loop
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- My ‘post attributes’ is missing from my WordPress install
- Reverse chronology of post listing
- Why do I need to use The Loop on pages (inside page.php etc)?
- WordPress Number of Posts Not Changing With posts_per_page
- how to display full post with pagination on home page
- Count singular post views automatically
- Looping through posts per category gives same posts for each category
- Forcing oembeds to top of post
- Find most recent authors
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Display All Sticky Post Before Regular Post
- Cannot access current post’s ID in custom plugin
- Can’t show comments count per post outside loop
- Get the author of the latest revision
- Accessing $post variable from template part
- How to have different content in the loop and single
- Specific loop in Shortcode
- Strange switch_to_blog() issue
- how to show all post in my page-grid.php template page
- Show a list of recently viewed posts to a user
- Multiple loops in same page, without duplicate content
- Use template of parent category for single post sub-categories
- Repost post on specific date every year
- How to use alternate post layout at key points in post loop?
- Alternate custom content in the loop
- Showing random content / pictures from earlier posts in a sticky post?
- Search widget breaks when using multiple loops?
- How to Display Post View Count
- Including text at the end of every post
- custom single.php not working
- Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?
- Adding variable for post title so post template can include auto-generated link to view on external website.com/{post title}
- Display Latest Post from all Categories
- How to display different single post template based on author?
- Auto Refresh Post List after X seconds
- The correct way to call posts with ajax
- How only display all post related to category
- Is it possible to have two different previews of a post (ie. two templates for one post)?
- custom wordpress post loop – hide iframe content
- Double count view in archive.php
- Divide Loop Into Days & Categories
- Converting multiple loops into one single loop with pagination
- Display posts with comments closed, with pagination?
- Group posts by year in loop
- How would I get 1 latest post from a query for 5 posts?
- Display page content AFTER a loop of posts
- Different template for posts of all subcategories of category
- While in “the loop”, detect if a post is the most recent
- Custom Post Templates
- Alternating post layout
- Check to see if specific loop has less than certain amount of posts
- Different style for most recent article
- Contact form 7 post loop [closed]
- Single post as homepage?
- Differentiate between posts and pages in search results
- Templating of a specific post ID
- Related posts loop based on tags AND categories doesn’t work without at least one tag assigned
- Loop through all product posts?
- How to display different number of posts
- If Specific Post, Link Elsewhere
- 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()
- Category Template: Need to display different content on first page of archives
- Change post_date to post_modified date on post template?
- What part of template to edit to remove category name from the top of posts?
- get_next_post() and get_previous_post() return wrong 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
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Display post from current category and same tag?
- Alternate row and columns every X posts
- page.php showing loop of posts and not page content
- Inserting custom data to the_post() during loop