【问题标题】:How to make wordpress title wrap to second line如何使wordpress标题换行到第二行
【发布时间】:2012-08-18 01:32:54
【问题描述】:

我正在使用自定义主题,我需要找到一种方法使标题换行到第二行。主题有一个轮播,标题显示在下方。目前,如果标题太长,则后面有“...”。我怎样才能阻止它并让它换行到第二行?

这是来自主题的代码

<div class="home-carousel">
  <ul>
    <?php
    $carimgheight = 120;
    if ( get_option('storefront_carousel_img_height' )) {$carimgheight = get_option('storefront_carousel_img_height' ); }
    $carimgwidth = 200;
    if ( get_option('storefront_carousel_img_number' ) == 2 ) {$carimgwidth = 428;}
    if ( get_option('storefront_carousel_img_number' ) == 3 ) {$carimgwidth = 276;}
    if ( get_option('storefront_carousel_img_number' ) == 5 ) {$carimgwidth = 154;}
    if ( get_option('storefront_carousel_img_number' ) == 6 ) {$carimgwidth = 124;} 
    //BEGIN Slider LOOP
    $loopcarousel = new WP_Query( array( 'post_type' => 'carousel' ) );
    while ( $loopcarousel->have_posts() ) : $loopcarousel->the_post();
    $buttonlink = get_post_meta($post->ID, "link", true);
    if(has_post_thumbnail()) {
    $carthumb = get_post_thumbnail_id(); 
    $carimage = vt_resize( $carthumb, '', $carimgwidth, $carimgheight, true );
    }
    ?>
        <li>
            <a href="<?php echo $buttonlink; ?>" title="<?php the_title(); ?>"><img alt="<?php the_title(); ?>" title="<?php the_title(); ?>" src="<?php echo $carimage['url']; ?>" width="<?php echo $carimage['width']; ?>" height="<?php echo $carimage['height']; ?>" /><?php if ( get_option('storefront_carousel_image_only') == "false" ) { ?><p><span class="carousel-title"><?php echo the_title(); ?></span></p><?php } ?></a>
        </li>
    <?php endwhile; //END SLIDER LOOP ?>

  </ul>

【问题讨论】:

    标签: wordpress title


    【解决方案1】:

    省略号 (...) 可以添加到客户端或服务器端。很有可能它是使用 CSS text-overflow: ellipsis; 添加的。查看页面的 HTML 源代码(输出,而不是模板),如果存在完整的标题文本,您可以假设省略号是在客户端添加的。如果您看到省略号,则需要在 WordPress 中找到添加它的自定义过滤器。

    假设.carousel-title 是应用样式的选择器,您可以注释掉或完全删除text-overflow: ellipsis; 规则。可能还有其他供应商前缀属性也需要删除,例如。 -o-text-overflow: ellipsis。可能还有一个 -moz-binding: 属性,用于为 Firefox 4 之前的版本添加省略号支持,您也可以将其删除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-09
      • 2011-02-24
      • 2010-09-23
      • 2023-01-13
      • 1970-01-01
      • 2021-12-11
      • 2013-03-29
      • 1970-01-01
      相关资源
      最近更新 更多