Is there any particular reason not to use the front-page.php
template file, and just not bother with trying to pull WordPress headers into external files?
Using the front-page.php
template file is easy:
- Create a new static Page, with any arbitrary name (let’s call it “Front Page”)
- Go to
Dashboard -> Settings -> Reading
and set “Front Page Displays” to “Static Page” - Set the “Front Page” dropdown to the “Front Page” static Page you created in step 1.
- Create a new template file for your theme, called
front-page.php
, and include in it your custom Loop code, above.
Also, you should properly filter the main Loop query as output on front-page.php
, rather than using the && $count <= 6
conditional in your call to the Loop.
I would recommend using a simple call to get_posts()
, and set the numberposts
argument to 6
.
Related Posts:
- When to use WordPress loop or Foreach loop?
- How do I query based on the modified date?
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- How do I query by post format in WordPress 3.1
- How to return results of a get_posts() in explicitly defined order
- Modify main WordPress loop with a parse_query filter
- How should I intercept the main query and inject custom join / order by / group by criteria
- query_posts sort in multiple directions
- Dynamically excluding current page id
- How to order results by date and meta key?
- Adding Variables to post query
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- How to insert content from another Custom Post type into Post?
- Placing post data (title, date, and excerpt) nested in static content
- query_posts() ALWAYS displays something?
- Displaying recent post excerpts on static front page
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- Custom loops, sticky posts, and pagination nightmare
- Filter Loop by Custom Field Value
- Modify loop but keep the original query, what am I doing wrong?
- Post per page not working if no category specified
- Calling Posts from Specified Cat
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Most Effective Method? Exclude Category and Number of Posts Per Page
- Script that gets the first tag of post and query all other posts with the same tag
- How to add an “or” instead of and “and” (&) in a WordPress query?
- Query add html after set amount of posts?
- Modify main loop query for paged and meta key
- Create a Loop with Posts Ordered by Most Recent Comments
- query_posts and sub pages?
- The_content display a different content from a previous loop
- Including post data in a sidebar occurring outside of and before the Loop
- Multiple loops with / without sticky posts and different post limits
- Limitless amount of posts in custom archive page
- query_post by title?
- Problem with ‘post__not_in’
- Retrieving 3 latest post from each of 5 different custom post types
- How do I prevent one of two multiple loops from repeating on a second page?
- Query post types with multiple keys
- How to sort by meta value?
- pagination in author.php template returns 404 error
- Show default content if custom WP_Query has no posts
- Display one latest post from multiple categories
- query recent posts from several categories
- Example Query Posts Showing the Latest Post with the Featured Image
- How to Loop within a Loop (Display Children and then Grandchildren)
- Get all posts WHERE custom_field is LIKE value
- WP Multisite Static Frontpage
- posts_per_page => 1 shows 2 posts
- Show individual author rank from query of cumulative post view count for all authors
- Exclude custom taxonomy tag from loop
- Tricky WP Query
- Change or update WordPress loop based on dropdown selection
- tax_query operator woes
- How To Get Posts With A Specific Word
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Using ajax with paging and a custom sub-query
- ACF Query meta_values don’t work with ‘offset’
- Make blog page show 10 on first page, 9 on every other page
- How to retrieve an array of post IDs by a particular value stored in a custom meta’s array
- How to get Related Custom Posts?
- define orderby URL with meta_key=post_views_count
- Query_posts and attachments
- Querying posts only if the current page is not paged?
- how to store wordpress loop in array?
- Custom taxonomy archive page problem
- Control content before and after custom post type loop
- Exclude posts by post meta value
- Single-page wordpress theme navigation
- meta tag placement for google verification
- attach CPT data to a taxonomy
- Separate First Post Loop
- Frontend form with multiple posts
- Custom Post type content within a slider
- Two Sections on Woocommerce Catergory Page [closed]
- Way to cache a query for 24 hrs
- 2 queries with counters
- Custom Post type showing up in loop, regular posts are not showing up
- Display 3 posts with different HTML markup using a loop
- Meta query stopped working
- Sticky posts don’t show up first in custom loop
- Want Page Descendants when using query_posts post_parent or child_of
- Querying a query
- query_posts meta_key with current date
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- how to add 4 post in one carousel slide
- Custom query for custom post type not getting correct post ID
- Highlight specific user with custom field value
- Create a hierarchical loop at predefined markup requirements
- custom loop issue
- Modify WordPress loop after it has been run
- Loop doesn’t display posts. It displays a link to the home page instead
- query_posts not working after wordpress 3.7 update
- Is that the query_posts() the real criminal here?
- single.php fires more than once after clicking on any post to view with different post id each time
- How to refine WP-Query with further criteria
- prevent display duplicate titles on main page
- Pagination in category.php not functioning
- Lots of SQL queries