Wordpress php if-statement

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?

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

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