• Resolved namisukichin69

    (@namisukichin69)


    Hi,

    I’m using below code to display posts.

    
    $args = array(
      'id' => 'my-list',
      'post_type' => 'my_custom_post_type', 
      'post_staus' => 'publish',
      'posts_per_page' => 2,
      'init_load' => 2,
      'template' => 'my-template',
    	 'meta_query'	=> array(
    		'relation'		=> 'AND',
    		array(
    			'key'		=> 'upload_type',
    			'value'		=> 'user',
    			'compare'	=> '='
    		)
    	)
     );
    	
     echo cpt_alm_render($args); 

    everything is working great, but the results doesn’t get affect by the ‘meta_query’ in the $arg (note: I’m using “Advanced Custom Fields” for meta fields)

    PS: @tushargohel thank you for your help in previous issues, I don’t have any other medium to contact you other than this support forum.

    • This topic was modified 4 years, 3 months ago by namisukichin69.
    • This topic was modified 4 years, 3 months ago by namisukichin69. Reason: addiitonal info
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author tushargohel

    (@tushargohel)

    Hi,

    We have one filter and you must need to add the following code in your functions.php file.

    
    add_filter('cpt_alm_query_args','cpt_alm_custom_meta_query',10,2);
    
    function cpt_alm_custom_meta_query($args, $id){
    	if($id == 'my-list'){
    		$args['meta_query'] = array(
    			'relation'		=> 'AND',
    			array(
    				'key'		=> 'upload_type',
    				'value'		=> 'user',
    				'compare'	=> '='
    			)
    		);
    	}
    	return $args;
    }
    
    Thread Starter namisukichin69

    (@namisukichin69)

    Great it works!!

    BTW, a heads up:

    the code example for cpt_alm_query_args, has a typo error in this page:

    https://plugins.blacktheme.net/cpt-ajax-load-more/docs/filters/

    please replace the filter from alm_query_args_movie_listing to cpt_alm_query_args.

    PS: It’s an awesome plugin, saved my day!!!

    Best Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to include meta_query in args’ is closed to new replies.