Skip to content

Instantly share code, notes, and snippets.

@Kennyboy7
Created August 9, 2021 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kennyboy7/5395b5ced6f741f032078e832b7f8e01 to your computer and use it in GitHub Desktop.
Save Kennyboy7/5395b5ced6f741f032078e832b7f8e01 to your computer and use it in GitHub Desktop.
X-Theme Pro Query String generator
<?
// Use this to get the correct format for a custom taxonomy to use in the Query String of a Looper
// This filter add a custom looper to get a custom post query
// its using the stadard built in WP post query structure
// add querys in the params areas and use the post_query as the hook
// Params need to be { "offset: 3"}
// Use the Post (Lists) element
add_filter( 'cs_looper_custom_post_query', function( $result, $args ) {
return get_posts( $args );
}, 10, 2);
// enter the details of the custom taxonomy below
// copy this into the Query Builder
// Use the wordpress quesry generator website to build the query https://generatewp.com/wp_query/
$tax_query[] = array(
'taxonomy' => 'years', // this is the custom taxonmony name
'field' => 'slug', // this needs to be slug
'terms' => '2018', // this is the value that you want to appear
'operator' => 'IN',
);
$query = array(
'post_type' => 'committee_minutes', // set this to the post type
'post_status' => 'publish', // only shows posts that are published
'ignore_sticky_posts' => 1,
//'posts_per_page' => 2,
'orderby' => 'title',
'order' => 'asc',
'tax_query' => $tax_query
);
// Uncomment the line below and view your website to be able to copy and paste the generated query string
//var_dump( http_build_query( $query ) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment