简体   繁体   中英

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?

如果有条件,请尝试以下内容,并让我知道结果如何。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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