fconsulting.php 2.29 KB
<?php 
function fenix_fconsulting ($atts)
    {
        $atts = shortcode_atts(
            array(
                'post'  => '',
                'id'    => ''
            ),
            $atts,
            'fenix_fconsulting'
        );

        $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="fenix_fconsulting shadow-sm">'.
                            '<div class="container">'.
                                '<div class="row">'.
                                    '<div class="col-12 pt-3 pt-md-5">'.
                                        '<h1>'.$post->post_title.'</h1>'.
                                    '</div>'.
                                '</div>'.
                            '</div>'.
                            '<div class="container-fluid">'.
                                '<div class="row flex-md-row-reverse">'.
                                    '<div class="col-12 col-md-6">'.
                                        (
                                            has_post_thumbnail($post->ID)?
                                              '<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="img-fluid mb-4 mb-md-0"/>':
                                              ''
                                        ).
                                    '</div>'.
                                    '<div class="col-12 col-md-6 text-end pt-md-4 mw-md">'.
                                        $post->post_content.
                                    '</div>'.
                                '</div>'.
                            '</div>'.
                        '</div>';
                    }
                wp_reset_postdata();

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