How to filter wp_get_recent_posts() to only posts that have thumbnails?

You can pass arguments to pass meta_query to your wp_get_recent_posts() function. wp_get_recent_posts() makes call for get_posts(), so you can make use of all the arguments get_posts() or WP_Query uses. As per your need. $args= array( ‘meta_query’ => array(array(‘key’ => ‘_thumbnail_id’)) ); $recent_posts = wp_get_recent_posts($args); Along with other arguments you want to pass to your function. … Read more

using filters on the function from class

If this is your own class that you’re doing this for, and can modify it, then you could pass the instance of the class as an addition argument to the filter callbacks: class Foo { …constructor, etc. function to_filter() { $output=”<div class=”wrap”>”; $output .= $this->another_function(); $output .= more html return apply_filters( ‘to_filter_name’, $output, $this ); … Read more

Filter on the day of the week from timestamp

This answer may help someone who really wants to customize their filters. With PhpStorm and breakpoints I could walk through how the meta_query is constructed before posts are fetched. There are no hook points in the flow that let developers accomplish this; I’ve used a SQL-injection trick to achieve the filter. // Do advanced SQL … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)