WordPress.org

Ready to get started?Download WordPress

Forums

Post Types Order
[resolved] Excluding galleries from post types order (10 posts)

  1. domnar
    Member
    Posted 1 year ago #

    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/

  2. codysg
    Member
    Posted 1 year ago #

    I'm having the same issue, but working with SK Testimonials. It reorders everything. There should be an exclude post type option.

  3. domnar
    Member
    Posted 1 year ago #

    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. :)

  4. codysg
    Member
    Posted 1 year ago #

    Programmatically? I was about to look into it.

  5. nsp-code
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. domnar
    Member
    Posted 1 year ago #

    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?

  7. nsp-code
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  8. klas_e
    Member
    Posted 1 year ago #

    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);
        }
  9. megabulk2
    Member
    Posted 1 year ago #

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

  10. Edusz
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.