Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • [email protected]

    (@dylanpetrohilosgmailcom)

    Hey hubspot currently lowers my score by 30 points, is this currently in the works?

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    I think my theory was off base, basically, I was trying to figure out how to runway fewer queries. The site I’m working on has hundreds if not thousands of posts and having a query for each style change seemed like it would eventually cause issues.

    <?php 
    $args = array( 'posts_per_page' => 7, 'category_name' => 'featured', 'paged'=>$paged);
    $featured = new WP_Query($args);
    if ($featured->have_posts()) : $count = 0; $paged = ( get_query_var('paged') > 1 ) ? get_query_var('paged') : 1 ; while ($featured->have_posts()) : $featured->the_post();  $count++;
    if ($count <= 1 && $paged === 1) : if ($count === 1);  ?>
    <?php get_template_part('front/top'); ?>
    
    <?php elseif (1 < $count && $count <= 2 && $paged === 1) :
                if ($count === 1); ?>
    <?php get_template_part('front/featured-loop-1'); ?>     
    <?php elseif (2 < $count && $count <= 3 && $paged === 1) : if ($count === 1); ?>
    <?php get_template_part('front/featured-loop-2'); ?>  
    <?php elseif (3 < $count && $count <= 4 && $paged === 1) : if ($count === 1); ?>    
    <?php get_template_part('front/featured-loop-1'); ?> 
            
    </section>
       <div class="col-lg-3 col-sm-12 col-md-12 double featured-post offset-lg-0 offset-0">
           
           <section class="featured-content row bottoms">
    
    <?php elseif (4 < $count && $count <= 8 && $paged === 1) : if ($count === 1); ?>    
    
    <?php get_template_part('front/featured-loop-3');?>  
    
    <?php else : if ($count === 9) ?>
               
    <br>
    <?php endif; endwhile; ?> <?php endif; ?>
    
    <!---! this should be a side bar of smaller older featured posts !---> 
           </section></div>          </section></div>   
    
    <?php 
    $args = array( 'posts_per_page' => 1, 'category_name' => 'podcast', 'paged'=>$paged);
    $featured = new WP_Query($args);
    if ($featured->have_posts()) : $count = 0; $paged = ( get_query_var('paged') > 1 ) ? get_query_var('paged') : 1 ; while ($featured->have_posts()) : $featured->the_post();  $count++;
    if ($count <= 1 && $paged === 1) : if ($count === 1);  ?>
    
    <?php get_template_part('front/social'); ?>    
    <?php get_template_part('front/social-loop'); ?>
    <?php endif; endwhile; ?> <?php endif; ?>
    
    <?php wp_reset_query(); ?>
    
    <?php get_template_part('front/sidebar-featured-widget'); ?>    
    

    This is what I eventually got… which is two queries instead of say 6 different ones.

    Thanks for helping me get there, appreciate it! I still need to clean up the code a bit after rethinking my idea, but that’s what I eventually created.

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    so after digging, I think my concept was somewhat off, appreciate the feedback!

    Basically, I ended up using this concept to kind of create another concept from here:
    https://wordpress.stackexchange.com/questions/225961/how-to-change-post-count-in-wordpress-loop

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    <?php 
    $args = array( 'posts_per_page' => 1);
    $featured = new WP_Query($args);
    if ($featured->have_posts()) : while ($featured->have_posts()) : $featured->the_post();?>
    <?php $do_not_duplicate = $post->ID; ?>	
    <?php get_template_part('front/top'); ?>
    <?php endwhile; endif; ?>
    <?php $featured->rewind_posts(); ?>
    
    <!---! this should be one post that looks different !---> 
    
    <?php get_template_part('front/top-stories'); ?>    
    <div class="container"><section class="row front">
    <section class="col-lg-9 col-md-12 col-sm-12 featured-post">
        
    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
    <?php get_template_part('front/featured-loop-1'); ?>    
    <?php endwhile; ?>
    <?php $featured->rewind_posts(); ?>
    <!---! this should be one post that looks different !---> 
    
    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
    <?php get_template_part('front/featured-loop-2'); ?>    
    <?php endwhile; ?>
    <?php $featured->rewind_posts(); ?>
    <!---! this should be one post that looks different !---> 
    
    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
    <?php get_template_part('front/featured-loop-1'); ?>    
    <?php endwhile; ?>
    <?php $featured->rewind_posts(); ?>
    <!---! this should be one post that looks different !---> 
        
    </section>
       <div class="col-lg-3 col-sm-12 col-md-12 double featured-post offset-lg-0 offset-0">
           
           <section class="featured-content row bottoms">
     
    
    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
    
    <?php get_template_part('front/featured-loop-3'); ?>    
    
       
    <?php endwhile; ?>
    
    <?php wp_reset_query; ?>
        
           
           
    </section></div>
        </section></div>

    @joyously appreciate the feed back and help!

    So, I’ve changed up my code, but it’s essentially doing the same thing and repeating the first post 4 times. Thanks for the help again everyone

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    @mailmechanic and @madeincosmos yall mind checking if youre seeing the same cache issues?

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    Yeah sadly I am, tho the server person says they disabled all caching, so maybe its something else

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    Using Nginx Settings, excluding from caching:

    /cart/
    /checkout/
    /my-account/

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    Okay try now, I just realized I broke something else, sorry.

    Thread Starter [email protected]

    (@dylanpetrohilosgmailcom)

    Yeah—tried this before I made the post—it didn’t work. Do folks have other thoughts on what could cause a JS conflict like this?

Viewing 9 replies - 1 through 9 (of 9 total)