Wordpress help needed - new WP_query

Discussion in 'PHP' started by thankyou, Sep 30, 2010.

  1. #1
    I am doing this for a friend (handing over project) and this problem has been haunting me for a couple of days. Frustrating.

    I have this code:
    <?php
    
    $query1 = 'category_name=featureditems&posts_per_page=10';
    $queryObject1 = new WP_Query($query1);
    						
    					if ($queryObject1->have_posts())  :  	
    					 $initialimg = 1;
    						while ($queryObject1->have_posts()): $queryObject1->the_post();
    					//echo "have post()";
    					 $initialimg = 1;
    						
    						//print "start while";
    						//echo "this is id: ".the_ID()." end ";
    						$class = "";
    						$fimage = get_post_meta(get_the_ID(), 'featuredimg', true);
    						$imgtxt = get_post_meta(get_the_ID(), 'imgcaption', true);
    						if ($fimage!="" and $imgtxt!="") {
    							if ($initialimg=="1") {
    								$class = 'class="show"';
    							}
    							
    						?>
    				
    							
    					
    	<a href="<?php the_permalink() ?>"><img src="<?php echo $fimage; ?>" alt="" title="<?php echo $imgtxt; ?>" /></a>
    
    								
    							<?php
    							$fimage = "";
    							$imgtxt = "";
    							$initialimg =0;
    						}
    						endwhile; 
    						//echo "Endwhile";
    
    			endif;
      
    
    ?>
    PHP:
    The code is suppose to retrieve post from the specific category.
    It works on my localhost xampp but it didn't work on my the server. I don't see any reason for it to behave that way. Any clues?

    Here is what I mean, something is suppose to appear at that big space: Singapore blogshops


    SOLVED

    I guess I solved it. I was using http://wordpress.org/extend/plugins/wp-hide-categories/ plugin. So my category posts is not displayed even though my codes is correct. Then I use http://blog.avirtualhome.com/wordpress-plugins/avh-extended-categories/ and it works well! =D Hope this can be help for the WP Theme Coders
     
    Last edited: Sep 30, 2010
    thankyou, Sep 30, 2010 IP