Categories
CMS Mastering Development Wordpress

How to get posts by meta value as multi-dimensional array?

I know how to get posts by a specific post meta when the meta value is a string. $meta_query = [ [ ‘key’ => $meta_key, ‘value’ => $meta_value, ‘compare’ => ‘=’ ] ]; $res_query = new \WP_Query( array( ‘post_type’ => $post_type, ‘order_by’ => ‘ID’, ‘meta_query’ => $meta_query, ‘posts_per_page’=> ‘-1’ ) ); $posts = $res_query->posts; But […]

How to get post from all custom post_type multisite to the main site with pagination ordered by date?

Currently this is my WordPress Multisite: Main site -Sub Site -Sub Site -Sub Site -Sub Site and this is the example code for getting all post from multisite : foreach( $blog_ids as $id ) { switch_to_blog( $id[‘blog_id’] ); $args = array(‘post_type’ => ‘events’, ‘posts_per_page’ => 2,’paged’ => $paged, $meta_query = array( ‘relation’ => ‘OR’, array( […]

Categories
CMS Mastering Development Wordpress

Get Current Post ID in functions php, meta query filter

How do I get the Current post ID in functions php when creating an meta query filter? I’ve made many attempts but all return Null. The filter works as expected when I manually input a number, but I need it to automatically echo the current post ID. Any guidance is appreciated, thanks. $args = array( […]

Get Current Page ID in functions php, meta query filter

How do I get the Current Page ID in functions php when creating an meta query filter? I’ve made many attempts but all return Null. The filter works as expected when I manually input a number, but I need it to automatically echo the current post ID. Any guidance is appreciated, thanks. $args = array( […]

Categories
CMS Mastering Development Wordpress

Get get Current Page ID in functions php, meta query filter

How do I get the Current Page ID in functions php when creating an meta query filter? I’ve made many attempts but all return Null. The filter works as expected when I manually input a number, but I need it to automatically echo the current post ID. Any guidance is appreciated, thanks. $args = array( […]

Categories
CMS Development Wordpress

Create a tree with categories with get_posts()

I have my posts using this code : $dataQuery = [ ‘numberposts’ => -1, ‘post_type’ => ‘documentation’, ‘meta_query’ => $meta_query, ]; $documentations = get_posts($dataQuery); Where $meta_query is an array. It’s working, I have my posts, but I want to show a tree with the categories and the posts inside ? Is it possible easily ? […]

Categories
CMS Development Wordpress

How to search a post knowing only taxonomy value?

I have created a search bar with auto-completion which trigger the property-search.php script. The search function is working well, but for the moment I can only search for the post name, eg: $args = array( ‘post_type’ => ‘zoacres-property’, ‘posts_per_page’ => absint( 10 ), ‘order’ => ‘DESC’, ‘s’ => esc_attr( $_GET[‘prop_name’] ), ‘meta_query’ => $meta_query, ‘tax_query’ […]