Sửa đổi câu lệnh where sql HOÀNG QUÁCH (ok)
https://www.hoangweb.com/wordpress-site/how-to-get-posts-data-wordpress
add_filter( 'posts_where' , 'posts_where' );
function posts_where( $where ) {
if( is_admin() ) {
global $wpdb;
if ( isset( $_GET['author_restrict_posts'] ) && !empty( $_GET['author_restrict_posts'] ) && intval( $_GET['author_restrict_posts'] ) != 0 ) {
$author = intval( $_GET['author_restrict_posts'] );
$where .= " AND ID IN (SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id=$author )";
}
}
return $where;
}<?php
//some function that modifies the query
function useless_condition ( $where ) { return $where . ' AND 1=1 '; }
//attach your function to the posts_where filter
add_filter( 'posts_where' , 'useless_condition' );
//get posts AND make sure filters are NOT suppressed
$posts = get_posts( array( 'suppress_filters' => FALSE ) );
?>PreviousCách lấy dữ liệu bài viết trong wordpress full HOÀNG QUÁCH (ok)NextdbDelta sql database (ok)
Last updated