key.php 1.35 KB
<?php 
function fenix_key ($atts)
    {
        $atts = shortcode_atts(
            array(
                'post'  => '',
                'id'    => ''
            ),
            $atts,
            'fenix_key'
        );

        $out = '';

        if ($atts['post']!=='')
            {
                $args = array(
                    'numberposts'   => 1,
                    'post__in'      => array($atts['post']),
                    'order'         => 'ASC',
                    'limit'         => 1
                );
                $posts = get_posts($args);
                foreach($posts as $key=>$post)
                    {   
                        $out = ''.
                        '<!--Медицинский центр под ключ -->'.
                        '<div class="container fenix_key shadow-sm">'.
                            '<div class="row">'.
                                '<div class="col-12 pt-3 pt-md-5">'.
                                    '<h1>'.$post->post_title.'</h1>'.
                                    $post->post_content.
                                '</div>'.
                            '</div>'.
                        '</div>';
                    }
                wp_reset_postdata();

                unset($key, $post, $posts, $args);
            }
        return $out;
    }
add_shortcode('fenix_key', 'fenix_key');