'post', 'show' => 4, 'template' => 'loop-template.php', 'css' => 'true' ), $atts)); $args = [ 'public' => true ]; $output = ''; $post_types = get_post_types($args, 'names'); $theme_directory = get_stylesheet_directory().'/'; $theme_template = $theme_directory.$template; if($css == 'true'){ $handle = 'ac_wp_custom_loop_styles'; $list = 'enqueued'; if (! wp_script_is( $handle, $list )) { wp_register_style( 'ac_wp_custom_loop_styles', plugin_dir_url( __FILE__ ) . 'assets/css/ac_wp_custom_loop_styles.css', array(), '20181007' ); wp_enqueue_style( 'ac_wp_custom_loop_styles' ); } } if( file_exists($theme_template)){ $template = $theme_template; } if (!in_array($type, $post_types)) { $output .= '

'; $output .= '' . $type . ' '; $output .= __('is not a public post type on this website. The following post type are available: -', 'ac-wp-custom-loop-shortcode'); $output .= '

'; $output .= ''; $output .= '

'; $output .= __('Please edit the short code to use one of the available post types.', 'ac-wp-custom-loop-shortcode'); $output .= '

'; $output .= '[ ac_custom_loop type="post" show="4"]'; return $output; } global $wp_query; $temp_q = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(array( 'post_type' => $type, 'showposts' => $show, 'orderby' => 'menu_order', 'order' => 'ASC' )); if (have_posts()) : $output .= '
'; while (have_posts()): the_post(); ob_start(); ?> '; endif; $wp_query = $temp_q; return $output; } add_shortcode('ac_custom_loop', 'ac_wp_custom_loop_short_code'); }