[theme-reviewers] Option to create child theme from theme option

Otto otto at ottodestruct.com
Wed Jan 22 21:17:22 UTC 2014


On Wed, Jan 22, 2014 at 3:03 PM, emin ozlem <eminozlem at gmail.com> wrote:
> I want to create a page template that displays <input>30</input> posts from
> <select> Uncategorized | Other </select> category, ordered by <select> ID |
> date </select>  etc. you get the idea.
>
> Essentially it'll just save the wanted query params in an option, and load
> them in "page.php" if chosen. Thats about it. No different than manually
> creating page-custom.php and writing in the query params by manually.

Also, and now I'm just being nitpicky, but that code could easily be
made theme-irrelevant. A rather straightforward plugin could make that
user-customizable and work on any theme whatsoever.

Think about it. You use some definable rewrite rules to detect the URL
you want to detect, then you're modifying the query, so you use the
pre_get_posts filter. There, you read in the options and apply them on
those specific cat archive pages.

And voila, your theme, knowing no wiser, shows your modified query
using the Loop as per usual. There's nothing theme-specific here
anymore, so it doesn't even *need* a Page Template. Customized URL
leads to customized query leads to result.

-Otto


More information about the theme-reviewers mailing list