Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp php get_the_category posts loop

<div class="container body-margin">
  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="card">
        <div class="row">
            <?php $url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), 'thumbnail' ); ?>
            <img src="<?php echo $url ?>" class="img-responsive card-image" />
        </div>

        <div class="row card-body">
            <?php

            $categories = get_the_category();
            if ( ! empty( $categories ) ) {
                echo '<div><a class="card-body-category" href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a></div>';
            }

            ?>
            <div><h4 class="card-body-title"><b><?php the_title(); ?></b></h4></div>
            <div><p class="card-body-date"><?php the_date(); ?></p></div>
        </div>
    </div>
  <?php endwhile; ?>
</div>
Comment

PREVIOUS NEXT
Code Example
Php :: php sort multi dimensional array 
Php :: php get client mac address 
Php :: header refresh page php 
Php :: drupal 7 hook_form_alter 
Php :: display custom post type 
Php :: woocommerce profile photo upload 
Php :: how to limit word in php 
Php :: database collection to array 
Php :: php array order by value 
Php :: get ip country 
Php :: cakephp 2.x join 
Php :: read pdf text in php 
Php :: json to array php 
Php :: brew downgrade php 8 to 7.4 
Php :: download html content from url php 
Php :: get month from database php 
Php :: create seed file laravel 
Php :: wordpress translate specific text php 
Php :: Syntax error or access violation: 1071 Specified key was too long; 
Php :: var_dump php 
Php :: offset codeigniter 3 
Php :: php remove and  
Php :: carbon format date in laravel 
Php :: php check session status 
Php :: custom 404 page in laravel 
Php :: define in php 
Php :: Wordpress admin settings form 
Php :: laravel 8 make model with migration and controller 
Php :: php function comment 
Php :: how to insert date in mysql using php 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =