• Resolved Ike Ten

    (@ike-ten)


    Hi @archetyped,

    Can you give examples for using parameters in cornerstone query?
    Am trying to filter posts that display with parameter.
    Example

    $args = array(
    	'post_type'  => 'my_custom_post_type',
    	'meta_key'   => 'age',
    	'orderby'    => 'meta_value_num',
    	'order'      => 'ASC',
    	'meta_query' => array(
    		array(
    			'key'     => 'age',
    			'value'   => array( 3, 4 ),
    			'compare' => 'IN',
    		),
    	),
    );

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Archetyped

    (@archetyped)

    Hi, Cornerstone supports the same parameters as WordPress’ own get_posts() function. See the official get_posts() documentation for more details.

    Thread Starter Ike Ten

    (@ike-ten)

    Thanks for the heads up.
    Will try it now. Giving a good example here would be great and beneficial to future users @archetyped. There’s so little info on your plugin on the web, makes me believe most users are advanced yet not all users are same. Some may need some few examples here and there.
    Kindly include loop examples like this on your knowledge base on your site. ??

    Thanks again

    • This reply was modified 7 years, 10 months ago by Ike Ten.
    Plugin Author Archetyped

    (@archetyped)

    Thanks for the feedback @ike-ten, I appreciate it.

    Thread Starter Ike Ten

    (@ike-ten)

    You welcome @archetyped.

    And am still waiting for the loop with Query Parameters example with cornerstone :).
    Am still learning myself hence an example will really help :).
    I went through the get_post() docs yet am still not very clear on the implementation.

    Thanks

    • This reply was modified 7 years, 10 months ago by Ike Ten.
    Plugin Author Archetyped

    (@archetyped)

    Just as with get_posts(), the parameters you would use really depend on how you want to modify the results of the query. Standard use does not require any additional parameters.

    Thread Starter Ike Ten

    (@ike-ten)

    Thanks for your patience and support @archetyped ,

    Yes I understand the parameters used really depend on how I wish to modify the results of the query. I finally want to come clear with a good example.

    If I wanted to query only 10 Latest posts ordered by title with post status of published using get_posts() I would do something like this below

    <?php
    $args = array( 'posts_per_page' => 10, 'post_status' => 'publish', 'order'=> 'ASC', 'orderby' => 'title' );
    $postslist = get_posts( $args );
    foreach ( $postslist as $post ) :
      setup_postdata( $post ); ?> 
    	<div>
    		<?php the_date(); ?>
    		<br />
    		<?php the_title(); ?>   
    		<?php the_excerpt(); ?>
    	</div>
    <?php
    endforeach; 
    wp_reset_postdata();
    ?>

    How can I do same with cornerstone? My issue is with this part $postslist = get_posts( $args ); where the $args is introduced.

    With get_posts() I know where to include the $args but with cornerstone am a bit not clear where to include the $args in the code <?php if ( cnr_have_children() ) : while ( cnr_have_children() ) : cnr_next_child(); ?>.

    An example loop with the above parameter using the cornerstone loop can really help clear things up for me.

    Thanks again.

    • This reply was modified 7 years, 10 months ago by Ike Ten.
    • This reply was modified 7 years, 10 months ago by Ike Ten.
    Thread Starter Ike Ten

    (@ike-ten)

    Hello @archetyped ??

    Plugin Author Archetyped

    (@archetyped)

    Hi, thanks for the additional details for clarification. Cornerstone does not currently support custom queries like that, though it is planned for a future update.

    I’m not sure if it will work, but you may get the results you want by adding the post_parent parameter to a custom WP_Query query (documentation). Set the value of post_parent to the current section using cnr_get_the_section(). See more section-specific functions in Cornerstone’s functions.php file.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Query Parameters’ is closed to new replies.