mercredi 6 mai 2015

Want to target specific posts in a loop

My Wordpress site has a loop that creates posts, and I want to target specific posts to change their css values.

html - index.php

<?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php
      get_template_part( 'content' );
    ?>
<?php endwhile; ?>

content.php

<?php
if (has_post_thumbnail()) {
$thumbnail_data = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'my-fun-size' );
$thumbnail_url = $thumbnail_data[0];
}
?>

<article id="post-<?php the_ID(); ?>" style="background-image:url('<?php echo $thumbnail_url ?>')" <?php post_class('container-fluid'); ?> >

 <div class="container-fluid">
  <div class="col-md-12 text-cell">
   <h2><a href="<?php the_permalink(); ?>" rel="bookmark"><?php  the_title(); ?></a></h2>
   <?php the_category(', '); ?>
  </div>   
 </div>

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

It was suggested that I use 'get_post_meta ...' but I am not familiar with how to use it. I just want to change css values (padding, font-size, etc) for different posts

Aucun commentaire:

Enregistrer un commentaire