WordPress.org

Ready to get started?Download WordPress

Forums

Simple Page Ordering
[resolved] How to make plugin work with custom post type (15 posts)

  1. Todd
    Member
    Posted 1 year ago #

    Hello

    I saw your post in the FAQ regarding custom post types, but I don't understand the instructions. In which file do we need to add the additional settings:

    hierarchical to true
    include page-attributes
    simple_page_ordering_is_sortable filter

    Thanks for your help!!

    http://wordpress.org/extend/plugins/simple-page-ordering/

  2. tnoguchi
    Member
    Posted 1 year ago #

    You'll need to add them when you register your custom post type using the register_post_type function.

    See the "Elaborate" example in the codex page that I linked above. If you're using a plugin to create your custom post type, try to see if you can add an argument:

    'supports' => array('title, thumbnail', 'page-attributes' )

    Also remember to add the 'orderby' => 'menu_order' and 'order' => 'ASC', to the following in your custom query:

    $args = array(
        'numberposts' => -1,
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'post_type' => 'staff'
    );
    $staff = get_posts($args);
  3. Todd
    Member
    Posted 1 year ago #

    I'm using a premium theme that has already made custom post types as part of the theme.

    In which file do you use 'register_post_type function?' If you can help me understand this, I might be able to figure out where to put the additional code you provided me.

    Thanks!

  4. tnoguchi
    Member
    Posted 1 year ago #

    I can't really answer this question without looking at the theme code. If you're using a premium paid theme, I suggest that you ask the theme developers directly. They'll probably have a support forum for this.

    If not, I would use a code editor to search the theme template files for the specific custom post type slug and or the term 'register_post_type'.

  5. Todd
    Member
    Posted 1 year ago #

    Ok. I found where to add the custom query.

    When you refer to 'register_post_type function' I suspect this would be in the theme's function file?

    Assuming this is correct, what code exactly would need to be added here?

  6. tnoguchi
    Member
    Posted 1 year ago #

    You can refer to the codex page that I linked above. As I mentioned, the 'elaborate' example shows you where the argument goes.

  7. Todd
    Member
    Posted 1 year ago #

    Ok. Found the right place to add the code.

    Got the hierarchical to true.

    But can you help me with:
    include page-attributes
    simple_page_ordering_is_sortable filter

    I don't see these in the link you referenced.

  8. Todd
    Member
    Posted 1 year ago #

    Figured out the 'page-attributes.'

    Just the page ordering left.

    Thanks!

  9. Todd
    Member
    Posted 1 year ago #

    Got everything to work (placed all the code where it needed to go).

    Still having one problem.

    When I got o adjust my order, the circle that spins to show it's 'working' never stops spinning and the change is not saved in the DB. What's causing this?

  10. tnoguchi
    Member
    Posted 1 year ago #

    The plugin won't add in changes to your template markup. Did you add the modified query code in your template?

    'orderby' => 'menu_order',
        'order' => 'ASC',

    It won't work without it.

  11. Todd
    Member
    Posted 1 year ago #

    Yes.

    It just keeps spinning.

    If I refresh the page, I notice that it saved the entry. But this is counter-productive. I should be able to move many items around before refreshing the page, no?

  12. rspilhaus
    Member
    Posted 1 year ago #

    The spinning should stop with the 'page-attributes' fix. Thanks tnoguchi!

  13. tnoguchi
    Member
    Posted 1 year ago #

    You're welcome. The FAQ on the plugin page isn't very clear, but it seems that in addition to adding the argument to page-attributes in the register_post_type function, it seems necessary to also add 'order' => 'ASC' in the template custom query in addition to the 'orderby' argument.

  14. Jake Goldman
    10up Engineer
    Plugin Author

    Posted 1 year ago #

    Actually, the plug-in is supposed to support EITHER post types with hierarchical support *or* page-attributes... bug there's a small bug in 2.1 that breaks that.

    Fixed in 2.1.1. Thanks for helping bring this to my attention!

  15. Todd
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.