• Resolved slb535

    (@slb535)


    It used to work. I’m not sure when it stopped working, unfortunately. I do know that it was before the upgrade to 4.4, because I just did that today. I’ve isolated the problem to be the 2nd query — the page stops loading after “Our Varied Practices Meet Your Needs” on the live server, but works perfectly when that chunk is removed.

    But again, on my localhost, it works beautifully. I’m hoping there’s something obvious and dumb that I did that newer versions of wordpress won’t tolerate.

    I’d appreciate any words of wisdom!

    <div id="content" class="grid_13">
        <?php if (!dynamic_sidebar('Alert')) : ?>
            <!--Wigitized 'Alert' for the home page -->
        <?php endif; ?>
        <h1>Committed to <br />Our Clients</h1>
    
        <div class="column front-left">
            <div class="news_headlines_home">
                <h2>Firm News</h2>
                <ul>
                    <?php
                    $args = array(
                        'cat' => 24, -33,
                        'posts_per_page' => 5,
                        'order' => 'DESC',
                        'post__in' => get_option('sticky_posts'),
                        'ignore_sticky_posts' => 1
                    );
                    $posts = query_posts($args);
                    if (have_posts())
                        while (have_posts()) : the_post();
                            ?>
                            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                            <?php
                        endwhile;
                    ?>
    
                </ul>
                <div class="smaller">
                    <?php
                    if (is_mobile()) {
                        get_sidebar('home');
                    }
                    ?>
                </div>
    
            </div><!--end news headlines -->
    
    <div id="photo-row">
        <h3>Our Varied Practices Meet Your Needs</h3>
        <?php
        $lawyer_profiles = get_posts('post_type=lawyer_profile&orderby=rand&numberposts=7&cat=-46');
    
        foreach ($lawyer_profiles as $post) {
            $lawyer_name = get_the_title();
            $first_name = substr($lawyer_name, 0, 15);
            ?>
            <div class="photo-block">
                <?php
                if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
                endif;
                ?>
                <div class="bar"></div>
    
                <h5 class="lawyer-name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
                <?php
                $practice_area_select = types_render_field("practice-area-select", array("raw" => "true"));
                echo '<h4 class="practice-name ' . $practice_area_select . '">';
    //	$practice_area_term = get_term_by('name', $practice_area_select, 'practice-area');
                echo '<span><a href="' . home_url() . '/practices-home/' . sanitize_title($practice_area_select) . '">' . $practice_area_select . '</a></span>';
                echo '</h4>';
                ?>
            </div>
            <?php
        }
        wp_reset_query();
        ?>
        <div class="clearfix"></div>
    </div> <!-- end photo-row-->
Viewing 1 replies (of 1 total)
  • Thread Starter slb535

    (@slb535)

    It’s probably worth noting (and I realized it this morning) that the same query (with different category restrictions) works just fine on the server on a regular page.

    I’ve also tried taking out the first query and the 2nd still doesn’t work on the home page. And I tried rewriting the queries (see below). Nothing. BUT IT STILL WORKS ON MY LOCALHOST. I’m completely at a loss. I’m picking apart what could be different on this home page.

    Here they are live. I can’t leave the home page live like this for too long…I do hope someone has the time/inclination to take a look.

    Works: https://johnsonandbell.com/crown-point-indiana/
    Doesn’t work: https://johnsonandbell.com/

    <?php get_header(); ?>
    
    <div id="content" class="grid_13">
        <?php if (!dynamic_sidebar('Alert')) : ?>
            <!--Wigitized 'Alert' for the home page -->
        <?php endif; ?>
        <h1>Committed to <br />Our Clients</h1>
    
        <div class="column front-left">
            <div class="news_headlines_home">
                <h2>Firm News</h2>
                <ul>
                    <?php
                    $args = array(
                        'cat' => 24, -33,
                        'posts_per_page' => 5,
                        'order' => 'DESC',
                        'post__in' => get_option('sticky_posts'),
                        'ignore_sticky_posts' => 1
                    );
                    $news_query = new WP_Query($args);
                    if ($news_query->have_posts())
                        while ($news_query->have_posts()) : $news_query->the_post();
                            ?>
                            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                            <?php
                        endwhile;
                    ?>
    
                </ul>
                <div class="smaller">
                    <?php
                    if (is_mobile()) {
                        get_sidebar('home');
                    }
                    ?>
                </div>
    
            </div><!--end news headlines -->
    
            <div id="photo-row">
                <h3>Our Varied Practices Meet Your Needs</h3>
                <?php
                $lawyer_args = array(
                    'post_type' => 'lawyer_profile',
                    'orderby' => 'RAND',
                    'posts_per_page' => 7,
                    'cat' => -46
                );
                $lawyer_query = new WP_Query($lawyer_args);
                if ($lawyer_query->have_posts())
                    while ($lawyer_query->have_posts()) : $lawyer_query->the_post();
                        ?>
                        <div class="photo-block">
                            <?php
                            if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
                            endif;
                            ?>
                            <div class="bar"></div>
                            <h5 class="lawyer-name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
                            <?php
                            $practice_area_select = types_render_field("practice-area-select", array("raw" => "true"));
                            echo '<h4 class="practice-name ' . $practice_area_select . '">';
                            echo '<span><a href="' . home_url() . '/practices-home/' . sanitize_title($practice_area_select) . '">' . $practice_area_select . '</a></span>';
                            echo '</h4>';
                            ?>
                        </div>
                        <?php
                    endwhile;
                ?>
                <?php
                wp_reset_query();
                ?>
                <div class="clearfix"></div>
            </div> <!-- end photo-row-->
    
            <div class="clearfix"></div>
        </div> <!-- end column front-left-->
        <div class="column front-right omega larger" >
            <!--  <div class="sidebar"> -->
            <?php
            if (!is_mobile()) {
                get_sidebar('home');
            }
            ?>
            <!--  </div> -->
        </div>
        <div class="clearfix"></div>
    </div><!--#content-home-->
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Second query works on localhost but not on server – what have I done wrong?’ is closed to new replies.