• Hi, i’m trying to display post with meta_key => ‘deco_special_project’
    like this:

    <div class="widget-content">
    
    		<?php
    		$args  = array(
    			'post_status'    => 'publish',
    			'meta_value'     => 1,
    			'posts_per_page' => 1,
    			'meta_key'       => 'deco_special_project',
    		);
    		$query = new WP_Query( $args );
    		// The Loop
    		while ( $query->have_posts() ) {
    		$query->the_post();
    		$post_id   = get_the_ID();
    		$thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'deco_post_300_200' ) [0];
    		?>
    
    		<article class="post-excerpt post-normal">
    
    			<a href="#">
    
    				<figure class="img-load">
    					<img src="<?php echo $thumb_url; ?>">
    				</figure>
    
    				<header>
    
    					<h4><?php the_title(); ?></h4>
    
    					<aside>
    						<time datetime="05.11.2014"><i class="de-icon-time"></i> 5 ноября</time>
    						<a href="#"><i class="de-icon-comment"></i> 10</a>
    						<span><i class="de-icon-views"></i> 3</span>
    					</aside>
    
    				</header>
    
    			</a>
    
    		</article>
    
    		<?php
    		}
    		wp_reset_query();
    		?>
    
    		<div class="blogroll-column blogroll-column-small">
    			<?php
    			$args = array(
    				'post_type'      => 'post',
    				'posts_per_page' => 5,
    				'post_status'    => 'publish',
    			);
    
    			$query = new WP_Query( $args );
    			// The Loop
    			while ($query->have_posts()) {
    				$query->the_post();
    
    				$post_id = get_the_ID();
    				?>
    			<article class="post-excerpt">
    
    				<a href="<?php echo get_permalink( $post_id ); ?>">
    
    					<header>
    
    						<h4><?php the_title(); ?></h4>
    
    						<aside>
    							<time datetime="05.11.2014"><i class="de-icon-time"></i> 5 ноября</time>
    							<a href="#"><i class="de-icon-comment"></i> 10</a>
    							<span><i class="de-icon-views"></i> 3</span>
    						</aside>
    
    					</header>
    
    				</a>
    
    			</article>
    			<?php
    			}
    			wp_reset_query();
    			?>
    
    		</div>
    
    		<article class="post-banner">
    
    			<a href="<?php echo get_permalink( get_the_ID() ); ?>">
    
    				<figure class="img-load">
    					<img src="/wp-content/themes/chai/assets/photo/thumb_google.jpg">
    				</figure>
    
    			</a>
    
    		</article>
    
    	</div>

    It does not work, but if i will delete meta_key from args, it will show post, can somebody help me?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘meta_key does not work, please help.’ is closed to new replies.