doucao1888 2018-06-20 05:51
浏览 29
已采纳

Wordpress php if-statement

Iamtrying to use a if-statement in order to use/not use a entry-title based on post format. The title should not be present for quotes and links.

At this point I can only put one of the post formats in the if statement at a time.

This works:

<?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; ?>

This does not work:

<?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; ?>

How can I make the last code to work?

  • 写回答

1条回答 默认 最新

  • dongtui0650 2018-06-20 06:04
    关注

    Try with below if condition and let me know what comes as a result.

    if ( !has_post_format( 'quote' ) && !has_post_format( 'link' ) ):
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?