• Resolved gnarlyinc

    (@gnarlyinc)


    When ever I add a category parameter to query_posts the them breaks.

    with no category parameter the code works fine.

    <?php
    
    			//The Query
    			query_posts( array (  'posts_per_page' => 5 ) );
    
    			while ( have_posts() ) : the_post(); 
    
    			?>
    
                <div class="home-post">
    
                <h2><a href="<?php	  the_permalink() ?>"><?php the_title(); ?></a></h2>
    
                <div id="date"><?php the_time('F j, Y'); ?> </div>
    
                <div class="clear"></div>
    
                <div class="post-content"><?php	 the_content('Read More &raquo;'); ?></div>
    
                <div class="post-clear"></div>
    			</div><!--/home-post-->
    
    			<?php endwhile; wp_reset_postdata(); wp_reset_query(); ?>

    as soon as I change the query to this:

    //The Query
    			query_posts( array ( 'category_name' => 'flash', 'posts_per_page' => 5 ) );

    The template breaks and yields some strange elements on the output code that are breaking the theme. Below is what is output when a category parameter is added to query_posts
    <u style="display:none"> <!--Web Page code is in here--></u>

Viewing 2 replies - 1 through 2 (of 2 total)
  • what theme are you working with?

    can the result be seen somewhere? (link to your site?)

    what is the full code of the template?

    have you tried to integrate a ‘if( have_posts())’ into the loop to check if your category query actually returns posts?

    Thread Starter gnarlyinc

    (@gnarlyinc)

    I tried if(have_posts())

    I was using a custom built theme that had worked before.

    I ended up figuring out what was causing the problem, someone had injected malicious links into the posts, causing the theme to break, much like the pharma hack. I’m still trying to find the source of the hack, or any backdoors.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding category parameter to query_posts breaks theme’ is closed to new replies.