The title says it all. I need working pagination, correct post count etc. Basically a new page for posts but with a filter for post formats.
Things I have tried so far:
1) Created a new rewrite rule for /no-formats/ that gets the id of the page that loads home.php and appends an argument (?no_post_format=true). Then hooked to ‘pre_get_posts’, checked for that argument and added a tax_query to the main query that excludes all posts with post formats.
This did not work because a rewrite rule to the home page causes a redirect to the actual home page. So /no-formats/ becomes /home/ and my argument is lost.
Not the actual code but to give you an idea of what I mean:
add_rewrite_rule( 'no-formats/?$', 'index.php?p='. get_option( 'page_for_posts' ) . '&no_post_format=true', 'top' );
2) Created a new page and tried to replicate the behavior of the page that displays posts and added the mentioned tax_query exclude. I just couldn’t come up with any way to get an exact duplication of the home page. Maybe have to dig deeper into WP core.
Does somebody have any ideas that could push me into the right direction?
For me I’d used a little different approach:
http://example.com/no-formats/
pre_get_posts
to set the proper query if neededtemplate_include
to force WP to usehome.php
instead of duplicating itNo more.
Remember to visit Settings->Permalinks in you dashboard to flush rewrite rules.
Edit
Note: you can use the same technique for a custom page template, with a custom loop via
new WP_Query()
:Pagination
For pagination, please refer to this Question/Answer.
Original Answer
Why not just exclude posts with post formats from the main posts archive?
This, paired with (I assume) custom template files (or custom page templates) for posts with post formats, would be a fairly simple way to show only “standard” posts in the archive index.