Support » Plugin: Simple Custom Post Order » Reverse order

  • Resolved ocaso

    (@ocaso)


    Hi. I made a custom order with your plugin. Can I reverse this order with a code? And not manually. Thank you for your help.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support mplusb

    (@mplusb)

    Hi @ocaso,

    Thank you for reaching out!
    Are you looking to reset the order?
    If yes, you can do this by going to your dashboard > Settings > SCPOrder > and there you will see Want to reset the order of the posts? > check the one you want > save.

    Warmly,
    Mihaela

    Thread Starter ocaso

    (@ocaso)

    No, not RESET. I want to REVERSE the order.
    If the order in my admin: 1 2 3 4 5
    I want to see this on the frontend: 5 4 3 2 1

    Plugin Support mplusb

    (@mplusb)

    Please add this code in your theme’s functions.php at the end

    
    add_action('pre_get_posts', 'custom_scproder_desc', 90 );
    function custom_scproder_desc( $wp_query ){
    	if ( is_admin() ){
    		return;
    	}
    
    	$scporder_options = get_option('scporder_options') ? get_option('scporder_options') : array();
    	$objects = isset($scporder_options['objects']) && is_array($scporder_options['objects']) ? $scporder_options['objects'] : array();
    
    	if ( isset( $wp_query->query['post_type'] ) ) {
            if ( ! is_array( $wp_query->query['post_type'] ) ) {
                if ( in_array( $wp_query->query['post_type'], $objects ) ) {
                    $wp_query->set('order', 'DESC');
                }
            }
        }else {
            if (in_array('post', $objects)) {
                $wp_query->set('order', 'DESC');
            }
        }
    
    }

    This will do it!

    Warmly,
    Mihaela

    Thread Starter ocaso

    (@ocaso)

    It works perfectly! Thank you very much!

    Hello, I need to change order like this:

    . If posts appear top in admin, then in front end posts must appear first
    . If posts appear bottom in admin, then in front end posts must appear last

    Is it possible?

    Thanks!

    Plugin Support mplusb

    (@mplusb)

    Hi @rolito,

    Thank you for reaching out!
    This is how the plugin works: the order the posts are in admin will be the same as the one on the front-end. The first post in admin will display first and the last one in admin will display last.

    For further questions, to avoid pile on (because this support thread was closed and related to another support question), please open a new support thread here: https://wordpress.org/support/plugin/simple-custom-post-order/

    Warmly,
    Mihaela

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Reverse order’ is closed to new replies.