Support

Account

Home Forums Add-ons Options Page Option page's field order is different from setting.

Solved

Option page's field order is different from setting.

  • I was able to have an option page under a custom post type by following the topic.

    http://support.advancedcustomfields.com/forums/topic/add-submenu-to-a-custom-post-type-menu/

    However, the field order is wrong. Let’s say I have few fields and arranged them by drag n’ drop in ACF setting page like so:

    1. name – text field
    2. longname – text field
    3. picture – image field
    4. summary – wysiwyg field

    Then I go to the options page and the field order is messed up.

    2. longname – text field (newest)
    4. summary – wysiwyg field
    1. name – text field
    3. picture – image field

    I think this is ordered by date of creation (the newer on top).

    The hook I used is init to register option page.
    I noticed, I dont know if this have to do with problem, I was redirected from
    edit.php?post_type=MY_POST_TYPE&page=MY_OPTION_PAGE_NAME
    to
    admin.php?page=MY_OPTION_PAGE_NAME
    after saving the options page and the field order is BACK TO NORMAL! strange…

    Any help will be appreciated.

  • Hi @nori2tae,

    I’m afraid that I can’t reproduce this issue on my end. Could you please tell me where do you put the code? Is it functions.php? If it is, you don’t need the init hook at all. You can add the options page as simple as this:

    if(function_exists(acf_add_options_page)){
        acf_add_options_sub_page(array(
            'page_title' 	=> 'Custom post options',
            'menu_title'	=> 'Options',
            'parent_slug'	=> 'edit.php?post_type=custom_post_slug',
        ));
    }

    I hope this helps.

  • @james

    Thanks for the solution.
    But unfortunately didn’t work for me.

    I did put the code in my functions.php and removed init hook as you suggested, but still ignoring my settings.

    I will keep finding the solution, however, since there are all fields I need I just use it as is.

    Thank you.

  • Hi @nori2tae,

    Could you please try this code?

    acf_add_options_sub_page(array(
        'page_title' 	=> 'Custom post options',
        'menu_title'	=> 'Options',
        'parent_slug'	=> 'edit.php?post_type=custom_post_slug',
    ));

    Please change the “custom_post_slug” with your custom post slug. Notice that we use acf_add_options_sub_page instead of acf_add_options_page.

    If there is no options page under the custom post type, please try to reproduce the issue on one of the WordPress’ stock themes with other plugins deactivated. If still no joy after that, please email support@advancedcustomfields.com and provide the detail of the issue and temporary credentials so we can check it up for you.

    I hope this helps.

  • @james

    I found the problem. As you said, I deactivated all plugins except ACF, and rechecked functions.php then I found a little function I wrote to reorder posts by date in admin page. That was it.

    I am really really embarrassed and sorry for the trouble.
    Just in case,

    function my_stupid_function($wp-query) {
    global $pagenow;
       if ( is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
         $wp_query->set( 'orderby', 'date' );
         $wp_query->set( 'order', 'DESC' );
       }
    }
    add_filter('pre_get_posts', 'my_stupid_function' );
    
  • Hi @nori2tae

    That is great. Glad that you found the issue. Yeah, sometimes we forgot about the little function we wrote before. Don’t feel embarrassed about it 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.