How display posts on main page with specific meta keys?

  • Unknown's avatar

    I’ve got two functions, first return meta_keys

    function deco_get_metakeys() {
    	$args  = array(
    		'post_type'      => 'post',
    		'posts_per_page' => - 1,
    		'meta_query'     => array(
    			'relation' => 'OR',
    			array(
    				'key'   => 'deco_post_is_slide',
    				'value' => 1,
    			),
    			array(
    				'key'   => 'deco_post_choose_redaction',
    				'value' => 1,
    			),
    			array(
    				'key'   => 'deco_post_interview',
    				'value' => 1,
    			)
    		)
    	);
    	$query = new WP_Query( $args );
    
    	while ( $query->have_posts() ) {
    		$query->the_post();
    
    		$exclude_post[] = $query->post->ID;
    	}
    
    	return $exclude_post;
    }

    and they don’t working, i can’t understand how write they correct.

    Second explode unnecessary meta keys.

    function excluded_pre_get_posts( $query ) {
    	add_action( 'pre_get_posts', 'deco_get_metakeys' );
    
    	if ( $query->is_main_query() ) {
    		$excluded = get_excluded_posts_fog_loops();
    		$query->set( 'post__not_in', $excluded );
    	}
    }

    I guess all problems in first function, i will very appreciate if somebody help, thanks.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    We blogger have no metadata access to WordPress.COM hosted blogs.

    If you don’t have a username account at WordPress.ORG click http://wordpress.org/support/ and register one on the top right hand corner of the page that opens, so you can post to the support forums there.

  • The topic ‘How display posts on main page with specific meta keys?’ is closed to new replies.