soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
316 stars 31 forks source link

Add Query Argument Options To Templates #303

Open Gibsonion opened 5 years ago

Gibsonion commented 5 years ago

Feature: Add the custom query options similar to those available in Easy Posts to be applied to a page template.

Uses: Remove the need to use Easy Posts, or any hard coding to create archive templates

Examples functionality: It's already in Easy Posts

albertso commented 5 years ago

Just include an easy posts with default query in the template, and assign the template to the archives you need.

What would be nice to have is an option to edit the easy posts template visually in the editor, add blocks etc. not just editing the php.

Gibsonion commented 5 years ago

I think you misunderstand the point, the point is to be able to visually edit an archive page without the need for Easy posts. If you could design the archive page the same way you design the single page, by using the Oxygen Dynamic data elements, but ones that would act like a loop instead of stand alone elements.

Frankly it should be very simple, by simply wrapping the loop query around the page placing the required elements inside would do the rest automatically.

Gibsonion commented 5 years ago

If Oxygen had hooks that could be wrapped around pages with PHP you could simply place a custom loop query around the page like so.

<?php
           $args = array(
            'post_type' => 'post',
            'posts_per_page' => '12',
            'order_by' => 'date', 
            'order' => 'DESC',
                'tax_query' => array(
                    array(
                        'taxonomy' => 'mytaxonomy',
                        'field' => 'slug',
                        'terms' => array ('term1', 'term2', 'term3')
                    )
                )
            );
            $query = new WP_Query( $args );
           ?>
           <?php if (have_posts()) : while( $query->have_posts() ) : $query->the_post(); ?>

And then your closing tags after.

And bobs your uncle you have a fully visually designable Archive template, WooCommerce Template, Custom Post Type Editor, you name it.

albertso commented 5 years ago

Okay, I see what you mean.

There is how to handle the wrapping of the loop, but it could be done by inheriting from another template.

I imagine seeing all posts in an archive and style them at the same time, where the first post (or any) could be editable at and the rest would update after changes.

Or, we could edit the template at the top, and have the Inner Content block at the bottom displaying the resulting loop. If we can do conditional stuff in the future, we could edit various templates for different conditions at the top, and see the resulting loop below.