2021年2月2日星期二

PHP conditional statement to display date on certain post types

I'm trying to set up a conditional statement to have all posts labeled as post_type "research" to NOT display the date and display the date on all other post types. I have the below, but it's showing the date on all posts.

    <?php get_header(); ?>    <div class="page page--post">        <?php get_template_part( '_partials/components/_breadcrumbs' ); ?>        <?php $post_type = get_sub_field( 'post_type' );    if ( $post_type == 'research'): ?>      <div class="page-section page-section--page-title">            <div class="container">                <div class="page__title-container wysiwyg-content">                    <h1 class="page__title"><?php the_title(); ?></h1>                            </div>            </div>        </div>  <?php else: ?>      <div class="page-section page-section--page-title">            <div class="container">                <div class="page__title-container wysiwyg-content">                    <h1 class="page__title"><?php the_title(); ?></h1>                  &nbsp;                  <p class="emphasized-text"><?php echo get_the_date('F j, Y') ?></p>                              </div>            </div>        </div>  <?php endif ?>    
https://stackoverflow.com/questions/66020669/php-conditional-statement-to-display-date-on-certain-post-types February 03, 2021 at 11:06AM

没有评论:

发表评论