display sort order
-
Hi – thanks for your plugin
I’ve got
[faqs style=”toggle” filter=”group-slug”]is there a way to display the group alphabetically? or some other order?
I think there are some WP codex parameters that might work in the shortcode but I can’t figure it out
thanks
-
Hi,
You can use the below-given shortcode to display the faqs groups in your desired order.
[faqs filter=”group-slug,another-group-slug”]
Let me know if you need any further assistance in this regard.
Thanks,
Hi sungraiz, this does not answer the question posed. The original poster (as well as myself) are looking for a way to alphabetically list the FAQs.
For example, let’s say the following is currently shown:
* Pear
* Apple
* Pineapple
* BananaIs there any way to make it go:
* Apple
* Banana
* Pear
* PineappleIt appears that the default sorting shows newest FAQs on top, but this isn’t always the most useful.
Hi,
Unfortunately, there is no option for this. You have to make the code modifications in order to achieve this.
Please add the below-given parameter as guided in the following screenshot.
'order' => 'ASC', 'orderby' => 'title',Thanks & Regards,
Can I suggest that you do a sort like we do for pages (Order)? Then I don’t need to go through and get a list of all of my group slugs. AND what works for groups is needed for questions too. Your plugin will probably not work for my project because of the sorting issue.
Hi @graftedin,
We will try to provide an option to sort the FAQs in the shortcode in a future update. For now, if you want to sort then you can follow the instructions provided by @sungraiz.
Thanks & Regards
@usmanaliqureshi the sort does not work while maintaining the groups.
@usmanaliqureshi The problem seems to be that in toggles_grouped_faqs you are looping through all of the groups rather than filter_array.
If filter_array is empty THEN you can loop through all groups. And as you loop though each group (filer_array or all groups) you can then call the individual group to get the rest of its info if needed…because filer_array won’t have all of that. And just like that your plugin works as expected.
Here is my replacement function. Can I ask that you add this to the next release.
private function toggles_grouped_faqs( $filter_array ) { if(!empty($filter_array)){ $faq_groups = $filter_array; } else { $faq_groups = get_terms( 'faq-group' ); } if ( ! empty( $faq_groups ) && ! is_wp_error( $faq_groups ) ) { foreach ( $faq_groups as $faq_group ) { if(!isset($faq_group->term_id)){ $faq_group = get_term_by( 'slug', $faq_group, 'faq-group' ); } $faqs_query = new WP_Query( array( 'post_type' => 'faq', 'posts_per_page' => -1, 'tax_query' => array( array ( 'taxonomy' => 'faq-group', 'field' => 'slug', 'terms' => $faq_group->slug, ) ), ) ); // FAQs Toggles if ( $faqs_query->have_posts() ) : echo '<h4 class="qe-faqs-toggles-group-title">' . $faq_group->name . '</h4>'; echo '<div class="qe-faqs-toggles-group">'; while ( $faqs_query->have_posts() ) : $faqs_query->the_post(); ?> <div class="nojs qe-faq-toggle active"> <div class="qe-toggle-title"> <strong><i class="fa fa-minus-circle"></i> <?php the_title(); ?></strong> </div> <div class="qe-toggle-content"> <?php the_content(); ?> </div> </div> <?php endwhile; echo '</div>'; endif; } // All the custom loops ends here so reset the query wp_reset_query(); } }-
This reply was modified 6 years, 9 months ago by
graftedin.
-
This reply was modified 6 years, 9 months ago by
The topic ‘display sort order’ is closed to new replies.