Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Anoop Ranawat

    (@anoopranawat)

    Yes you can re-arrange..
    Just open faq.php file and see line no. 74,75
    ‘$orderby ‘= ‘post_date’;
    ‘$order’= ‘DESC’;’

    you can make ‘$order’ = ‘ASC’;

    Thanks

    If you have all FAQs displayed together (i.e. not using categories) and wish to control the exact order in which they appear, edit faq.php as follows:

    Line 74
    change $orderby = ‘post_date’;
    to $orderby = ‘menu_order’;

    Line 75
    change $order = ‘DESC’;
    to $order = ‘ASC’;

    These 2 changes will change the sort order in the front-end display.

    Line 45
    change ‘supports’ => array(‘title’,’editor’,’thumbnail’,’excerpt’)
    to ‘supports’ => array(‘title’,’editor’,’thumbnail’,’excerpt’,’page-attributes’)

    This changes enables a new box “Attributes” in the FAQs edit admin (right hand side of page). There you’ll see a box called “Order”. Set the value of “Order” for each FAQ (1,2,3,etc) to set the order in which they appear. “Order” can also be set via the “Quick Edit” feature when listing FAQs.

    Remember to keep careful note of changes made to this core plugin file as you will need to reapply the changes if you upgrade (deliberately or inadvertently!) the plugin.

    Thanks! @axses, this was very helpful. I am not sure why this isn’t built in to the plugin as the default ordering.

    How about adding ordering as a shortcode attribute to the plugin? I’ve modified the plugin myself to do this, code here:

    function sp_faq_shortcode( $atts, $content = null ) {
    
    	extract(shortcode_atts(array(
    		"limit" => '',
    		"category" => '',
    		"order" => '',
    	), $atts));
    
    	// Define limit
    	if( $limit ) {
    		$posts_per_page = $limit;
    	} else {
    		$posts_per_page = '-1';
    	}
    	// Define limit
    	if( $category ) {
    		$cat = $category;
    	} else {
    		$cat = '';
    	}
    
    	if(!$order) {
    		$order = 'DESC';
    	}
    
    	ob_start();
    
    	// Create the Query
    	$post_type 		= 'sp_faq';
    	$orderby 		= 'post_date';
    
    	$query = new WP_Query( array (
    								'post_type'      => $post_type,
    								'posts_per_page' => $posts_per_page,
    								'orderby'        => $orderby,
    								'order'          => $order,
    								'cat'          =>   $cat,
    								'no_found_rows'  => 1
    								)
    						);
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Re-arrange FAQs?’ is closed to new replies.