• Someone know how can i save all custom fields order by post?

    Because i need save the order by post id and get the same order on front-end theme.

    I think the meta-box-order is saving only by post type for all post.

    If someone know anything about how can do something like that, please! Let me know.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m sorry, I don’t understand what you are trying to do. You can order posts by ID without custom fields. Set “orderby” query var in the “pre_get_posts” action to “ID”. What is the purpose of the meta box value you are trying to save? Some sort of ordering criteria? Unless it’s a numeric value to use in ordering, it doesn’t make sense to save ordering criteria like ID, date, title, etc. per post. It has to apply to all posts.

    Please try to clarify, thanks.

    Thread Starter Cristian Ávila

    (@cristianmavila)

    Oh sorry! I’m trying to use the drag and drop of fields to display the same order on front-end! I was tracking the ajax post on admin and i figure out that’s saving as a meta box order on database.

    Thanks for answer.

    Moderator bcworkz

    (@bcworkz)

    The advanced custom field meta boxes? Is the ordering saved in post_meta for the specific post by any chance? Then you can get that data with get_post_meta(). You’d have to equate whatever data is saved with the field names. (I’ve no idea what ACF is saving for ordering.) On the front end, run a loop to output all the fields, using the order data to manage what field is output when in the loop. PHP’s switch/case structure might be a good way to equate order data with field names.

    Another ordering possibility would be to use CSS flex-box with the “order” property. Output the critical properties in a <style> block somewhere early on the template. The CSS that does not change with order can be added to style.css or the additional CSS panel of the customizer.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘custom fields meta box order by post’ is closed to new replies.