Support

Account

Home Forums Add-ons Repeater Field Author page with custom post type subfield filter meta query in m Reply To: Author page with custom post type subfield filter meta query in m

  • Thanks.
    I solved the problem.

    I added this in function.php:

    function comapa_posts_where( $where ) {
    	$where = str_replace("meta_key = 'users_$", "meta_key LIKE 'users_%", $where);
    	return $where;
    }
    
    add_filter('posts_where', 'comapa_posts_where');

    And I modified query on author.php:

    
            <?php
    	        global $wpdb;
        		$author_name = get_the_author();
                $authorid = get_the_author_meta('ID');
    			$cat = get_queried_object();
                $args =  array(
                    'post_type' => "any",
                    'post_status' => "publish",
                    'orderby' => "date",
                    'order' => 'DESC',
                    'posts_per_page' => 12,
    				'cat' => $cat->term_id,
    				'meta_query' => array(
    				
    		          array(
    		               'key' => 'users_$_user_name',
    		               'value' => $authorid,
    		               'compare' => '='
    		          )
    		          
    				 
    				)
    				
                );
    
                $query = new WP_Query($args);
             
    		?>