• Hello Im trying to ignore ‘post’ using code from your page https://www.nsp-code.com/ignore-sort-apply-for-certain-query-on-post-types-order/

    add_filter('pto/posts_orderby/ignore', 'theme_pto_posts_orderby', 10, 3);
    function theme_pto_posts_orderby($ignore, $orderBy, $query)
    {
        if( (! is_array($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'post') ||
        (is_array($query->query_vars)   &&  in_array('post', $query->query_vars)))
                $ignore = TRUE;
        return $ignore;
    }

    This code unfortunatelly does not work, it ignores ordering for all post_types include portfolio. Can you please provide code that ignore post_type ‘post’ only?

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Maya

    (@tdgu)

    Hi,
    The code looks right to me, if need to ignore the order for post queries. Might be worth trying and checking if the $query->query_vars[‘post_type’] is not empty, as if does, is a post query actually. So the code becomes:

    add_filter('pto/posts_orderby/ignore', 'theme_pto_posts_orderby', 10, 3);
        function theme_pto_posts_orderby($ignore, $orderBy, $query)
        {
            if( 
            ( ! isset ( $query->query_vars['post_type'] )   ||  empty ( $query->query_vars['post_type'] ) ) ||
            (! is_array($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'post') ||
            (is_array($query->query_vars)   &&  in_array('post', $query->query_vars)))
                    $ignore = TRUE;
            return $ignore;
        }

    Thanks

    Thread Starter gracispavel

    (@gracispavel)

    Unfortunately that didnt help me. Same as before, this code block all taxonomies not only post taxonomy.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ignore posts’ is closed to new replies.