Search
 
SCRIPT & CODE EXAMPLE
 

PHP

order by pre get posts

add_action( 'pre_get_posts', 'standout_sort' );
function standout_sort( $query ) {
    if ( $query->is_main_query() && !is_admin() && is_post_type_archive('team') ) {
        $query->set('orderby', 'meta_value_num');  
            $query->set('meta_key', 'sort_order');  
            $query->set('order', 'ASC'); 
    }
} 
Comment

PREVIOUS NEXT
Code Example
Php :: twig render string 
Php :: adjacent post sort order by post title 
Php :: php get today at 3pm 
Php :: php get referrer ajax 
Php :: foreach tableau php 
Php :: php pass 2 date value to javascript 
Php :: laravel compare request domain and app domain and request original domain 
Php :: change sender name laravel 
Php :: laravel getClientOriginalExtension 
Php :: php pdo delete 
Php :: heroku deploy php 
Php :: log php 
Php :: You need to grant write permissions for PHP on the following directory: /var/www/html/prestashop 
Php :: Redirect User To Different Page 
Php :: How to run PHP script every 5 minutes 
Php :: php call non static method from static method 
Php :: php $_server 
Php :: php session destroy not working 
Php :: Laravel unique with Validation rule 
Php :: laravel where condition with if 
Php :: how to enable autoreload on save 
Php :: laravel collection find 
Php :: laravel maintenance mode custom class 
Php :: withcookie function in php 
Php :: livewire calendar for laravel 9 
Php :: laravel use npm package 
Php :: string concatenation in php 
Php :: mysql gone away error in php 
Php :: firebase realtime database get all data 
Php :: laravel all 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =