• Esther

    (@esther-moudy-gummere)


    I’d like for my posts to appear in a certain order on category pages, which theoretically is possible by only slightly modifying the snippet from the add_post_type_support in function reference here like this:

    //ATTRIBUTES
    ////
    add_action('init', 'my_custom_init');
    function my_custom_init() {
    	add_post_type_support( 'post', 'page-attributes' );
    }

    The meta-box for “order” comes up and it saves, but unfortunately doesn’t affect the order in which the posts appear.
    Anybody have any ideas how to make it happen?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The Order page attribute typically only applies to the post list table in the admin area, and only to hierarchical posts, of which regular posts are not.

    Still, the value is saved as you noted, so a theme could potentially make use of this value in listing posts or pages. It sounds like your theme does not support this, which is quite typical. You could create a child theme (or make a simple plugin) that alters category queries to orderby ‘menu_order’ in the ‘pre_get_posts’ action.

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to add "order" function to posts…’ is closed to new replies.