代码之家  ›  专栏  ›  技术社区  ›  Fjott

wordpress php if语句

  •  0
  • Fjott  · 技术社区  · 6 年前

    iamtrying使用if语句,以便使用/不使用基于post格式的条目标题。标题不应出现在引号和链接中。

    此时,我一次只能在if语句中放入一种post格式。

    这项工作:

    <?php if ( !has_post_format( 'quote' ) ): // Quote ?>
    
    <?php the_title( '<h2 class="entry-title" itemprop="name headline"><a href="' . esc_url( get_permalink() ) . '" itemprop="url">', '</a></h2>' ); ?>
    
    <?php endif; ?>
    

    这不起作用:

    <?php if ( !has_post_format( 'quote' ) || !has_post_format( 'link' ) ): // Quote or Link ?>
    
    <?php the_title( '<h2 class="entry-title" itemprop="name headline"><a href="' . esc_url( get_permalink() ) . '" itemprop="url">', '</a></h2>' ); ?>
    
    <?php endif; ?>
    

    如何使最后一个代码生效?

    1 回复  |  直到 6 年前
        1
  •  3
  •   Akshay Shah    6 年前

    尝试以下条件,让我知道结果是什么。

    if ( !has_post_format( 'quote' ) && !has_post_format( 'link' ) ):