'post', 'show' => 4, 'template_path' => get_stylesheet_directory() . '/', 'template' => 'loop-template', 'css' => 'true', 'wrapper' => 'true', 'ignore_sticky_posts' => 1, 'orderby' => '', 'order' => 'DESC', 'class' => 'c-accl-post-list', 'tax' => '', 'term' => '', 'timber' => false, 'ids' => '' ), $atts)); $template_type = $type; //default orderby if ($type == 'post' && $orderby == '') { $orderby = 'date'; } elseif($orderby == '') { $orderby = 'menu_order'; } if($ids != ''){ $ids = explode(',', $ids); $type = 'any'; $orderby = 'post__in'; } $args = [ 'public' => true ]; $output = ''; $post_types = get_post_types($args, 'names'); $theme_directory = $template_path; if ($timber != false){ $twig_template_folder = $theme_directory . 'templates/'; $template = (substr($template, -5) === '.twig') ? substr_replace($template ,"",-5) : $template; $theme_template = $template . '.twig'; $theme_template_type = $template . '-' . $template_type . '.twig'; }else{ //$theme_extention = (substr($template, -4) === '.php' || substr($template, -5) === '.twig' ) ? '' : '.php'; $template = (substr($template, -4) === '.php') ? substr_replace($template ,"",-4) : $template; $theme_template = $theme_directory . $template . '.php'; $theme_template_type = $theme_directory . $template . '-' . $template_type . '.php'; } $wrapperOpen = ($wrapper == 'true') ? '
' : ''; $wrapperClose = ($wrapper == 'true') ? '
' : ''; 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(), '20181016'); wp_enqueue_style('ac_wp_custom_loop_styles'); } } if($timber != false){ if (file_exists($twig_template_folder.$theme_template_type)) { $template = $theme_template_type; }elseif (file_exists($twig_template_folder.$theme_template )) { $template = $theme_template; }else{ $template = "loop-template.twig"; } }else{ if (file_exists($theme_template_type)) { $template = $theme_template_type; }elseif (file_exists( $theme_template )) { $template = $theme_template; }else{ $template = "loop-template.php"; } } if (!in_array($type, $post_types) && $type != 'any') { $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' => $orderby, 'order' => $order, 'ignore_sticky_posts' => $ignore_sticky_posts, 'taxonomy' => $tax, 'term' => $term, 'post__in' => $ids )); if (have_posts()) : $output .= $wrapperOpen; if($timber === false){ while (have_posts()): the_post(); ob_start(); ?> The Timber plugin is not active.
Activate Timber or set timber='false' in the short code

" ?>