Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wp_display_post( $atts, $content = '' ) {
- global $post;
- // Shortcode Parameter
- $atts = shortcode_atts(array(
- 'limit' => 5,
- ), $atts, 'wp_display_post');
- // WP Query Parameter
- $args = array (
- 'post_type' => 'post',
- 'post_status' => array( 'publish' ),
- 'posts_per_page' => $atts['limit'],
- 'ignore_sticky_posts' => true,
- );
- ob_start();
- $query = new WP_Query( $args );
- // If post is there
- if( $query->have_posts() ) {
- while ($query->have_posts()) : $query->the_post();
- ?>
- <div class="wp-post-main">
- <div class="wp-post-title"><h4><?php the_title(); ?></h4></div>
- <div class="wp-post-cnt-wrp">
- <?php
- if ( FLBuilderModel::is_builder_enabled( $post->ID ) ) {
- // Enqueue styles and scripts for this post.
- FLBuilder::enqueue_layout_styles_scripts_by_id( $post->ID );
- // Render the builder content.
- FLBuilder::render_content_by_id( $post->ID );
- } else {
- the_content();
- }
- ?>
- </div>
- </div>
- <?php
- endwhile;
- }
- wp_reset_postdata(); // Reset WP Query
- $content .= ob_get_clean();
- return $content;
- }
- add_shortcode( 'wp_display_post', 'wp_display_post' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement