WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Post Types Order] Excluding galleries from post types order

[Resolved] [Plugin: Post Types Order] Excluding galleries from post types order

  • I am using the wordpress plugin “post types order” for a while now which so far was very useful to sort various types of posts. The problem is, that the plugin only worls for ALL post types, or (if deactivated) for none.

    This means, that you cannot set an order for your WordPress gallery, since “post types order” will allways overwrite it. Does anybody have an idea how I could exclude the gallery from being affected by the plugin?

    I took a look at the code, but sadly I did not manage to find a way to exclude galleries.

    http://wordpress.org/extend/plugins/post-types-order/

Viewing 9 replies - 1 through 9 (of 9 total)
  • I’m having the same issue, but working with SK Testimonials. It reorders everything. There should be an exclude post type option.

    I think you can exclude post types in the extended version of the plugin. But since the extended version would be a bit of overkill for my purpose, I’m just trying to find a way to exclude the gallery. 🙂

    Programmatically? I was about to look into it.

    Plugin Author nsp-code
    Participant

    @nsp-code

    If you need to exclude, the Autosort option should be turned OFF, then include ‘orderby’ => ‘menu_order’ within the queries where you require the custom order to be set.
    I confirm the advanced version contain such feature, where you can exclude certain post types from within the admin while using the Autosort ON.

    Oh another little follow-up question: If I upgrade to the pro version, do I need to set the orders again, or does the plugin simly take over the setting from the basic version?

    Plugin Author nsp-code
    Participant

    @nsp-code

    The Advanced Post Types Order plugin use a different code/technique which allow to order the post types for archive sections (all objects of a post type), within each categories (any taxonomies terms). For that reason the old defined order is useless. However we are working to find methods to make this possible.

    A quick fix is to open post-types-order.php ange change the CTPOrderPosts function on line 85:

    if ($options['adminsort'] == "1")

    to

    if ($options['adminsort'] == "1" && $query->query_vars['post_type'] !== 'attachment')

    Full function after change:

    function CPTOrderPosts($orderBy, $query)
        {
            global $wpdb;
    
            $options = get_option('cpto_options');
    
            //ignore the bbpress
            if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("reply", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "reply")))
                return $orderBy;
            if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("topic", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "topic")))
                return $orderBy;
            error_log(($query->query_vars['post_type']), 0);
            if (is_admin())
                    {
                        if ($options['adminsort'] == "1" && $query->query_vars['post_type'] !== 'attachment')
                            $orderBy = "{$wpdb->posts}.menu_order, {$wpdb->posts}.post_date DESC";
                    }
                else
                    {
                        if ($options['autosort'] == "1")
                            $orderBy = "{$wpdb->posts}.menu_order, " . $orderBy;
                    }
    
                    //);
            return($orderBy);
        }
    megabulk2
    Member

    @megabulk2

    Thanks for the solution, klas_e! That was driving me a little nuts.

    I have the plugin through my theme: Avada 3.0.1 (by themeforest). How can I resolve this issue?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] [Plugin: Post Types Order] Excluding galleries from post types order’ is closed to new replies.