D
D
Denis2020-06-25 16:46:13
WordPress
Denis, 2020-06-25 16:46:13

How to display a specific caption depending on the post tag (wordpress)?

I give the whole code (for the sake of completeness), but I'm only interested in the lower part (after !!!!!!!) - how to correctly write the condition in php. The bottom line is this: when displaying posts (cards), there was a check - if the post has a label (ID=14), then one inscription on the card is displayed, if another label (not with ID=14), respectively, another inscription. In general, everything revolves around the post label. Question: how to correctly implement this condition in php? Thanks in advance.

$args = array(
            'numberposts'  => null,
            'post_type'    => 'portfolio',
            'suppress_filters'  => true,
        );

        $posts = get_posts($args);

        foreach ($posts as $post) {
            setup_postdata($post); ?>
        <!-- Portfolio item -->
        <a class="portfolio-content__item" href="<?php $thumb_img = get_post(get_post_thumbnail_id());
                                                        echo $thumb_img->post_excerpt; ?>" target="_blank">
            <img class="portfolio-content__item_img bw" src="<?php the_post_thumbnail() ?>" alt="myname" />
            <div class="portfolio-content__item_overlay" style="display: none;">
                <span><?php the_title() ?></span>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                <?php $terms = get_the_terms($post->ID, 'cms');
                    if ( ) {
                        the_excerpt() . ' | ' . '<i class="fab fa-phone"></i>';
                    } else {
                        the_excerpt();
                    }
                    ?>
            </div>
        </a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-06-25
@Cobra8106

https://developer.wordpress.org/reference/function...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question