dp926460 2016-07-26 21:30
浏览 70

更改Wordpress中动态内容的边框颜色

Sincere apologies if this has been asked before. To be honest I didn't know what terms to search for well enough to find relevant content.

Goal: My company has a press page that is built using some custom PHP built into Wordpress. The press page can be seen here: http://www.hospitalityq.com/press

My marketing manage would like to change the light gray border on the press to colors within our company palette. We would have 5 colors that we would like the press items to rotate throughout. Is it possible to color each press article with it's own color and have that done through adding on to our PHP script?

Below is a copy of our existing script.

I hope that makes sense. I'm happy to post a mockup if that's easier.

Best, Dan

<?php

$postID = get_the_ID();
$meta = get_post_meta($postID);
?>
  <!--pre>
  <?php
  //var_dump ($meta);
  ?>
  </pre-->
<?php
  if( has_post_thumbnail( $postID ) ):;
?>
  <div class="clear-after">
  <div class="post-image">
    <a
       href="<?php echo $meta['hq_news_articles_link'][0] ?>"
       class="vc_read_more"
       title="Read about <?php the_title_attribute(); ?>"
       target="_blank">
      <?php the_post_thumbnail($postID); ?>
    </a>
  </div>
<?php
  endif;
  $infoClass = 'post-info '. (!has_post_thumbnail( $postID ) ? 'no_image' : '');
?>
<div class="<?php echo $infoClass; ?>">
 <h4>
    <a
       href="<?php echo $meta['hq_news_articles_link'][0] ?>"
       class="vc_read_more"
       title="Read about <?php the_title_attribute(); ?>"
       target="_blank"
     >
      <?php the_title();?>
    </a>
  </h4>
      <h5>
        <?php the_date('F j, Y');?>
      </h5>
      <p><?php
          echo substr(get_the_excerpt(),0, 115);
          // echo wp_trim_words(get_the_excerpt(), 20);
          ?>&hellip;
        <br><a
       href="<?php $meta['hq_news_articles_link'][0] ?>"
       class="hq_press-read-more"
       title="Read about <?php the_title_attribute(); ?>"
       target="_self"
     >
       Read article
    </a>
   </p>
</div>
</div>
  • 写回答

2条回答 默认 最新

  • duansha8115 2016-07-26 21:40
    关注

    I would use CSS nth-child:

    .company {
      border: 1px solid black;
    }
    
    .company:nth-child(5n+1) {
      border-color: red;
    }
    
    .company:nth-child(5n+2) {
      border-color: green;
    }
    
    .company:nth-child(5n+3) {
      border-color: yellow;
    }
    
    .company:nth-child(5n+4) {
      border-color: blue;
    }
    
    .company:nth-child(5n+5) {
      border-color: purple;
    }
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>
    <div class="company">company</div>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口