Aleks Szymanski
Forum Replies Created
-
AuthorPosts
-
April 30, 2020 at 11:28 pm in reply to: The post_type value is blank in query_vars for geodirectory-archive.php #543298This reply has been marked as private.April 27, 2020 at 10:37 pm in reply to: The post_type value is blank in query_vars for geodirectory-archive.php #542983
Sorry if I wasn’t clear. In “geodirectory-archive.php”, I need to get the “post_type” from query_vars:
$post_type = $wp_query->query_vars['post_type'];
This works for gd_placecategory and gd_eventcategory, but not gd_peoplecategory.
Event Category – https://tennisletics.com/explore/places/category/resorts/
Place Category – https://tennisletics.com/explore/events/category/camps/
People Category – https://tennisletics.com/explore/people/category/coaches/The “post_type” key returns blank from query vars for People Category.
September 13, 2019 at 7:23 pm in reply to: Hide past events with when using gd_linked_posts shortcode #508110Thank you very much Alex, this worked perfectly! 🙂
Thanks Alex. Is there some sort of filter/action I can add in functions.php to sort by featured first?
Hello, just checking to see if there is any update on this?
Thanks!
Thanks Alex and Kiran! I’ll look forward to the solution. 🙂
Thanks Kiran! I’ll check that out.
For now, I did end up finding a solution:
// Main args $post_type = 'gd_place'; $args = array( 'post_type' => $post_type, 'posts_per_page' => 5 ); // Sort by highest rated using GeoDirectory query args filter $temp_args = $args; $geodir_sort = 'high_rating'; // or 'overall_rating_asc' $test_instance = array ( 'post_limit' => 5, 'post_type' => $post_type, 'sort_by' => $geodir_sort ); $temp_args['is_geodir_loop'] = true; $temp_args['order_by'] = $geodir_sort; $temp_args = apply_filters( 'geodir_widget_listings_query_args', $temp_args, $test_instance ); $widget_listings = geodir_get_widget_listings( $temp_args ); $post_ids = array(); foreach( $widget_listings as $listing ) { $post_ids[] = $listing->ID; } $args['post__in'] = $post_ids; $args['order'] = 'DESC'; $args['orderby'] = 'post__in'; // The loop $places = new WP_Query($args); if ( $places->have_posts() ) : while ( $places->have_posts() ) : $places->the_post(); echo '<div class="listing"><div class="the-title">'.get_the_title().'</div></div>'; endwhile; wp_reset_postdata(); endif;
Basically you build your query args, retrieve post ids using geodir widget query args filter, and then pull those into the main args using “post__in”.
Hope this helps someone else in the future!
Awesome, thanks so much!
Thanks Alex. Is there any way one of your developers can provide a simple solution for ordering by highest rating using a simple WP_Query? I checked widget code and it’s a little above my pay-grade. 🙂
Maybe a simple filter I can add to functions.php?
Note: I’m trying to accomplish this on a regular WP page template, not an geo directory template. I’ve even tried this:
$posts = new WP_Query(array( 'post_type' => 'gd_place', 'posts_per_page' => 5, 'sort_by' => 'overall_rating_desc', ));
July 5, 2019 at 4:34 pm in reply to: Can I create a custom WP_Query using lat/lon and near radius? #496432Ok thanks guys.
Hi Alex, update on this one. I ended up using custom “geodirectory-archive.php” theme template override and pulled the query_vars and customized the parameters for each WP_Query loop on the page. It works perfectly, even with search results since I’m still utilizing the original query_vars.
Thanks for the reply!
Kiran, this works perfectly so far! I’ve tested a theme option as well as a post type field for Place. Thanks so much for this!
Shoutout to Paolo for pushing this through. 🙂
That makes sense. I appreciate you looking into this. Looks like others are continuing to struggle with ACF as well. 🙂
This reply has been marked as private. -
AuthorPosts