Wednesday, February 8, 2023
HomeWordPress Developmentphp - Shortcode Shows 2 instances

php – Shortcode Shows 2 instances


Created the shortcode however it shows twice each time I exploit it.

Right here is the code:

perform blog_cta() {

    $blog_cta="";
    $blog_cta .= '<div class="article-cta-box">';

            $cta_box_section_heading = get_field('cta_box_section_heading', $post->ID);
            $cta_button = get_field('cta_button', $post->ID);

             if ( $cta_box_section_heading !== '' ) {
                    $blog_cta .= '<div class="article-cta-box--col-one"><img src="' . get_template_directory_uri() . '/property/photos/article-cta-box-art.svg" alt="" function="presentation"></div><div class="article-cta-box--col-two">
                                            <img src="' . get_template_directory_uri() . '/property/photos/gust-launch-small-logo.svg" alt="" function="presentation">
                                            <div class="cta-details-wrapper"><h3>' . $cta_box_section_heading . '</h3>';
             }
             if ( $cta_button !== '' ) {
                $blog_cta .= '<div class="btn-wrapper">
                                                        <a href="' . $cta_button['url'] . '" goal="' . $cta_button['target'] . '" class="main-btn">' . $cta_button['title'] . '</a></div></div></div>';
             }

    $blog_cta .= '</div>';

    return $blog_cta;

}

add_shortcode('location_blog_cta', 'blog_cta');

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments