• Hey everyone,
    I am trying to create my first wordpress theme and I am lost. I am trying to query all posts with a particular meta tag called featured_post in order to populate a jquery slider that will be in the home page but all I get is a blank site.

    Here is the code that does not work.

    $query = query_posts(array(
    'post_type' => 'post',
    'meta_query' => array(
    	array(
    		'key' => 'featured_post',
    		'value' => '1',
    		'compare' => '=='
    	)
    )
    $queryObject = new WP_Query($query);
    ?>
    		<div id="content">
    			<div id="my-slideshow">
    				<ul class="bjqs">
    					<?php
    						//while (have_posts()) : the_post();
    					if ($queryObject->have_posts()) {
    						while ($queryObject->have_posts()) {
    							$queryObject->the_post();
    
    					<!--<li class="slide">
    						<?php the_post_thumbnail('full', array('title' => ""));?>
    						<div class="expand"></div>
    						<div class="slide_txt">
    							<h2 class="post_title"><?php the_title_attribute()?></h2>
    							<div class="post_desc">
    								<p><?php the_content(); ?></p>
    							</div>
    							<div class="btn_push">
    								<a href="<?php permalink_link(); ?>" class="more_btn">See More Projects</a>
    							</div>
    						</div>
    					</li>
    					<?php }
    						}
    					//endwhile;?>-->
    				</ul>

    I have had results before but unfortunately it gives me all of the posts and not the ones with that meta tag. I don’t know what I’m doing wrong but I have searched everywhere and can’t seem to get any progress. Thanks.

    P.S. The query I had that did work for me is this one…

    query_posts('cat=projects');
    ?>
    		<div id="content">
    			<div id="my-slideshow">
    				<ul class="bjqs">
    					<?php
    						while (have_posts()) : the_post();
    					?>
    					<li class="slide">
    						<?php the_post_thumbnail('full', array('title' => ""));?>
    						<div class="expand"></div>
    						<div class="slide_txt">
    							<h2 class="post_title"><?php the_title_attribute()?></h2>
    							<div class="post_desc">
    								<p><?php the_content(); ?></p>
    							</div>
    							<div class="btn_push">
    								<a href="<?php permalink_link(); ?>" class="more_btn">See More Projects</a>
    							</div>
    						</div>
    					</li>
    					<?php endwhile;?>
    				</ul>

  • The topic ‘Trying to get results from a query – NEWB HELP!’ is closed to new replies.