Forum Replies Created

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter ferdalkrmn

    (@ferdalkrmn)

    @bedas this is the code that I am trying to save, but WordPress admin panel does not allow me to do so. I don’t know where I am making the mistake.

     <div class="container"> <!-- container start -->
          <div class="row overflow-hidden"> <!-- row start -->
         <?php if ( have_posts() ) : while( have_posts()  ) : the_post(); ?>
                  <div class="col-xs-6 col-sm-6 col-md-6 col-lg-4 col-xl-3"> <!-- columns start -->
                    <a href="<?php the_permalink(); ?>">
                      <div class="title-box mx-auto mb-0">
                        <h1 class="title-color">
                            <?php
                          $title = get_the_title();
                          if ($title):
                            echo the_title();
                          else:
                            echo "No Title";
                          endif;
                          ?>
                        </h1>
                        <?php
                            if( has_post_thumbnail() ):
                                the_post_thumbnail('full', [ 'title' => 'Feature image', 'class' => 'img-fluid']);
                            else:
                        ?>        
                            <img class="img-fluid" src="<?php echo get_template_directory_uri() . "/images/bg.jpg"; ?>">
                        <?php endwhile; endif; ?>
                      </div>
                    </a>    
                  </div> 
          </div>
        </div> 
    • This reply was modified 1 year, 10 months ago by ferdalkrmn.
    Thread Starter ferdalkrmn

    (@ferdalkrmn)

    @bedas I tried but then I got problems to close my div tags

    Thread Starter ferdalkrmn

    (@ferdalkrmn)

    @faisalahammad Hello, thank you so much for the help it really fixed my problem, but I have updated the code like this, it’s working but I just want to make sure that I didn’t make a mistake, the code is working perfectly ??

    <div class="container"> <!-- container start -->
            <div class="row overflow-hidden"> <!-- row start -->
                <?php foreach ( $related_posts as $post ) : setup_postdata( $post ); ?>
                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-4 col-xl-3">
    					<a href="<?php the_permalink(); ?>">
                        <div class="title-box mx-auto mb-0">
                             <h1 class="title-color"><?php the_title(); ?></h1>
                            <?php
                            if( has_post_thumbnail() ):
                                the_post_thumbnail('full', [ 'title' => 'Feature image', 'class' => 'img-fluid']);
                            else:
                        ?>        
                            <img class="img-fluid" src="<?php echo get_template_directory_uri() . "/images/bg.jpg"; ?>">
                        <?php endif; ?>    
                        </div></a>
                    </div>
                <?php endforeach; wp_reset_postdata(); ?>
            </div>
        </div>
    <?php endif; ?>
Viewing 3 replies - 16 through 18 (of 18 total)