BLOG LOOPS Not WORKING CORRECTLY -

by MIKE9004   Last Updated September 11, 2019 16:08 PM - source

I am having issues with my blog loops. I had someone customize by site but they made a mistake with the blog posts. ISSUE: I have three different pages that feature blog categories (events, news, The Journal). Although the posts are appearing on their correct pages (e.g. Events blog post 1, appears on Events Page), every blog post is also appearing on the “The Journal” page. Moreover, when you go to the Events or News page and click on a post’s ‘read more’, it opens up on “The Journal” page- not on the Events or News page.
IDEALLY: I want each blog category to appear and open solely on their individual pages. Below you can see the relevant index.php php code (i think) for “index.php” ”single.php", "tag.php", "The Journal.php", "content-tag.php", "taxononomy-blog_category.php" . I would appreciate if someone can help me out. Thanking you in advance for any guidance, Mike

INDEX.PHP get_header(); ?>

">Read More " class = "blog-post-mywebsite"> ', '', false ); echo $my_date; ?> ', '' ); else : the_title( '', '' ); endif; ?>
    <?php if( $images ): ?>

        <div id="slider" class="flexslider">
        <ul class = "slides">
            <?php foreach( $images as $image ): ?>
                <li>
                    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                </li>
            <?php endforeach; ?>
        </ul>
        </div>

    <?php endif; ?>

        <?php if( get_field('video') ): ?>
            <div id="slider" class="flexslider">
                <div class="video-fit">
                    <?php the_field(video); ?>
                </div>
            </div>
        <?php endif; ?>

<div class = "row" style = "padding: 32px 0;">
    <div class="col-md-4" style = "padding-left: 0px !important;">
        <?php if( get_field('address') ): ?>
            <h4>Address</h4>
            <?php the_field(address); ?>
        <?php endif; ?>

        <?php if( get_field('telephone') ): ?>
            <h4>Telephone</h4>
            <?php the_field(telephone); ?>
        <?php endif; ?>

            <?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
                ADDTOANY_SHARE_SAVE_KIT( array(
                    'buttons' => array( 'facebook', 'twitter', 'google_plus', 'pinterest', 'linkedin' ),
                ) );
            } ?>
    </div>

    <div class = "col-md-8">
        <div>
            <?php if( get_field('blog_text') ): ?><?php the_field(blog_text); ?><?php endif; ?>
        </div>

    </div>
</div>


</article><!-- #post-## -->

THE-JOURNAL.PHP

'post', 'post_status' => 'publish', 'orderby' => 'DESC' ); $my_query = null; $my_query = new WP_Query($args); ?> have_posts()) : $my_query->the_post();?> current_post == 0 && !is_paged() ) : ?>

"> 'img-fluid' ) ); ?> ... ">Read More
      </div>

    <?php endif; ?>

  <?php endwhile; ?>

  <?php
    $args=array(
       'post_type' => 'post',
       'post_status' => 'publish',
       'offset' => '1',
       'orderby' => 'DESC'
    );

    $my_query2 = null;
    $my_query2 = new WP_Query($args);
  ?>
    <?php $i = 0; ?>
  <?php while ($my_query2->have_posts()) : $my_query2->the_post();?>
    <?php if($i % 2 == 0) { ?>
        <div class="row">
              <?php
              }
              ?>
          <div class="col-md-6 thumbnail">
            <a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_post_thumbnail( 'full', array( 'class'  => 'img-fluid' ) ); ?></a>
            <h3><?php echo get_the_date(); ?></h3>
            <h2 class = "thumbnail-title"><?php echo the_title(); ?></h2>
            <h3 style = "padding-top: 0px; padding-bottom: 30px;"><a href = "<?php echo get_permalink(); ?>">Read More</a></h3>
          </div>
          <?php $i++; if($i % 2 == 0) { ?> </div><?php } ?>
 <?php endwhile; ?>
  <?php wp_reset_query(); ?>
<?php endif; ?>

CONTENT-TAG.PHP

'img-fluid' ) ); ?> CONTENT-CATEGORY.PHP

'img-fluid' ) ); ?> Taxonomy-blog_category.php

.thumbnail img { max-height: 350px; }

  <div class = "row journal-blog">
    <div style = "margin-top: 50px;">
      <?php
        if ( have_posts() ) : ?>

        <?php $i = 0; ?>

            <?php
            /* Start the Loop */
            while ( have_posts() ) : the_post(); ?>
           <?php if ( $i % 2 == 0 ) { ?><div class="row"><?php } ?>
             <div class="col-md-6 thumbnail">
               <?php the_post_thumbnail( 'full', array( 'class'  => 'img-fluid' ) ); ?>
               <h3><?php echo get_the_date(); ?></h3>
               <h2 class = "thumbnail-title"><?php echo the_title(); ?></h2>
               <h3 style = "padding-top: 0px; padding-bottom: 30px;"><a href = "<?php echo get_permalink(); ?>">Read More</a></h3>
             </div>
        <?php $i++; ?>
        <?php if ( $i % 2 == 0 ) { ?></div><?php } ?>
            <?php endwhile;
        endif; ?>
      <?php wp_reset_query(); ?>
    </div>
    <? if ($i % 2 != 0) { ?></div><?php } ?>
    <div class = "col-md-3">
      <?php get_sidebar(); ?>
    </div>
  </div>
</div><!-- #primary -->

Tags : php loop blog


Related Questions


WordPress Recent Posts - Loop

Updated December 24, 2018 05:08 AM

Display subcategories in dropdown

Updated June 01, 2015 14:03 PM

Blog posts repeat

Updated October 25, 2017 20:08 PM

Pagination on a underscore custom theme

Updated May 23, 2018 10:08 AM

Custom Pagination is Broken

Updated October 26, 2017 00:08 AM