1

I need to use custom loop from visual composer:

if( function_exists('vc_map') ) {

    vc_map( array(
        'base' => 'minimag_popular_post_custom',
        'name' => esc_html__( 'Popular Post Custom', "minimag-toolkit" ),
        'class' => '',
        "category" => esc_html__("Minimag Theme", "minimag-toolkit"),
        'params' => array(
            array(
                // this param
                "type" => "loop",
                "heading" => esc_html__("Display Custom Loop", "minimag-toolkit"),
                "param_name" => "custom_loop",
            )
        ),
    ) );
}

In past I've used vc_link which had the proper function to retrieve the value in the correct form: vc_build_link($href).

There is some function to extract the data from loop parameter? I've looked in the reference but I've not find nothing.

Here an example of the output that I need to parse:

size:8|order_by:date|order:DESC|post_type:post|categories:32,5|by_id:1537,1673

I need to have something like:

$myVar['size'] = 8;
$myVar['order_by'] = 'date';
$myVar['order'] = 'DESC';
$myVar['post_type'] = 'post';
$myVar['categories'] = array(32,5);
$myVar['by_id'] = array(1537,1673);
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
red
  • 1,529
  • 1
  • 12
  • 33

2 Answers2

0

tested and working :)

list($args, $wp_query) = vc_build_loop_query($atts["custom_loop"]);

while ( $wp_query->have_posts() ) {
   $wp_query->the_post();
}

wp_reset_postdata();
felixhirschfeld
  • 316
  • 2
  • 7
-2

If you know your query I like to create a shotcode in the functions.php of my child-theme to create that. You can pass parameters to create different output and you can use such a shortcode everywhere in your site.