繁体   English   中英

在长回显字符串php中添加div

[英]Adding div inside long echo string php

我试图在这个回显字符串中添加一个 div,查看了所有其他主题,但这个字符串比那里讨论的问题要复杂一些。

全码:

          <div class="breadcrumb hidden-xs" typeof="BreadcrumbList" vocab="https://schema.org/">     
          <span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" class="home" href="<?php echo home_url('/');?>" title="<?php echo bloginfo('name');?>"><span property="name">Home</span></a><meta property="position" content="1"></span><span class="division">/</span><span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" class="post-root post post-post" href="<?php echo home_url('/blog/');?>" title="Ga naar Nieuws."><span property="name">Nieuws</span></a><meta property="position" content="2"></span><span class="division">/</span>
    <span property="itemListElement" typeof="ListItem">
                <?php
$categories = get_the_category();
$separator = ',';
$output = '';
if($categories){
  $i=1;
  foreach($categories as $category) {
      if($i==1){
      if($category->cat_name!="Homepage"){
    echo '<a property="item" typeof="WebPage" href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>';
  $i++; } } } } ?>
      <meta property="position" content="3"></span>
    <span class="division">/</span><span property="itemListElement" typeof="ListItem"><span property="name"><?php the_title();?></span><meta property="position" content="4"></span></div>

我需要编辑的代码:

echo '<a property="item" typeof="WebPage" href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>';

所以我喜欢在 .$category->cat_name 之前添加这个<span property="name">

和结束</span>在结束</a>之前

提前致谢!

好的,我已经知道了:

echo '<a property="item" typeof="WebPage" href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">' . '<span property="name">'.$category->cat_name.'</span></a>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM