Support » Plugin: Flexible Posts Widget » Custom field in flexible post query?

  • Resolved The Three

    (@3wwwgr)


    hello there!

    It is possible “adding” custom query in flexible post query? For example i want to add to existing flexible post template this query:

    new WP_Query( array( 'year' => $today["year"], 'monthnum' => $today["mon"], 'day' => $today["mday"], 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) );

    (wpb_post_views_count is counting the pages views)… So i want to get the top viewed posts from current day… How can this be done in any flexible post template?

    https://wordpress.org/plugins/flexible-posts-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author DaveE

    (@dpe415)

    Howdy,

    Yup, it is possible to adjust the query called by the widget via a hook that is in place just before the widget runs the query: $args = apply_filters( ‘dpe_fpw_args’, $args );

    Here’s a thread with example usage.

    Cheers!

    Thread Starter The Three

    (@3wwwgr)

    Sorry but i don’t know how to use the “apply_filter”. I must include this $args in function.php? Something like this:

    function most_popular( $args ) {
            $today = getdate();
    	$args = array( 'year' => $today["year"], 'monthnum' => $today["mon"], 'day' => $today["mday"], 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num' );
    
    	return $args;
    add_filter( 'dpe_fpw_args', 'most_popular' );

    Is that corrent?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field in flexible post query?’ is closed to new replies.