• Resolved _jerryjee

    (@_jerryjee)


    Hi :
    I’m writing a query_post like this .

    $args = array(
            'post_type' =>  DEBBING_TYPE_SLUG,
            'post_status'   =>  'publish',
            'meta_query'    => array(
                array(
                    'relation' => 'AND',
                    'status_clause' => array(
                        'key'       => '_debbing_status',
                        // 'type'      => 'NUMERIC',
                    ),
                    'order_clause' => array(
                        'key'       => '_debbing_order',
                        // 'type'      => 'NUMERIC',
                    ),
                )
            ),
            'orderby' => array(
                'status_clause'       => 'DESC',
                'order_clause'     => 'DESC',
            )
        );

    query_posts($args);

    And use query monitor the sql is below :

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
    FROM wp_posts
    INNER JOIN wp_postmeta
    ON ( wp_posts.ID = wp_postmeta.post_id )
    INNER JOIN wp_postmeta AS mt1
    ON ( wp_posts.ID = mt1.post_id )
    WHERE 1=1
    AND ( ( wp_postmeta.meta_key = ‘_debbing_status’
    AND mt1.meta_key = ‘_debbing_order’ ) )
    AND wp_posts.post_type = ‘debbing’
    AND (wp_posts.post_status = ‘publish’
    OR wp_posts.post_status = ‘private’)
    GROUP BY wp_posts.ID
    ORDER BY CAST(wp_postmeta.meta_value AS SIGNED) DESC, CAST(mt1.meta_value AS SIGNED) DESC
    LIMIT 0, 10

    Every time i reload the page ,the result is different .

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter _jerryjee

    (@_jerryjee)

    Problem 1:
    Every time i reload the page ,the result order is different .

    Problem 2:
    Look like the result is less . I seted the _debbing_status = 0 , for 3 posts.
    But the program only didsplay 2 records.
    If i change the _debbing_status = 0 , for 4 posts , only didsplay 3 records.

    AnyOne knows how to slove the problem ?

Viewing 1 replies (of 1 total)
  • The topic ‘Mutlipe Custom fileds order by’ is closed to new replies.