Friday, August 12, 2022
HomeWordPress DevelopmentKind posts utilizing a number of customized fields and menu_order in single...

Kind posts utilizing a number of customized fields and menu_order in single question?


I’ve a customized submit sort known as Workers, and on the Workers web page I am hoping to type the entries in two units: first, I’ve a customized true/false subject known as “keep on with prime”, and I might like these posts to show first within the checklist. Secondly, I might like the remainder of the posts to show alphabetically by final title (one other customized subject). I can get this fundamental ordering to work with the question arguments under, however the place I am having a problem is in attempting to get these posts which are set to “keep on with prime” to order by the menu_order attribute- thus, I might like to have the ability to manually specify the order of these posts with the “keep on with prime” subject set to true through the menu_order option- I am questioning if that is doable utilizing a single question, or if I might must create and merge two queries to attain this outcome?

Here’s what I’ve so far to allow placing the “sticky” posts at prime, adopted by the remainder in alpha by final title, however the sticky posts additionally at the moment seem alpha by final title, and I am not fairly certain the place/easy methods to specify menu_order for that group. Please let me know if that is sufficiently clear, and thanks for any perception right here!

$args = array(
    'post_type'             => 'employees',
    'posts_per_page'        => -1,
    'post_status'           => 'publish',
    'meta_key'              => 'last_name',
    'order'                 => 'DESC',
    'meta_query' => array(
        // verify for sticky posts through customized subject; then order these first through orderby array
        array (
            'relation' => 'OR',
            'sticky_true' => array(
                'key'   => 'make_post_sticky',
                'worth' => '1',
            ),
            'sticky_false' => array(
                'key'   => 'make_post_sticky',
                'worth' => '0',
            ),
        ),
    ),
    'orderby'  => array( 
        'sticky_true' => 'DESC',
        'last_name' => 'ASC'
    ),
);

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments