How to remove the post pagination (Next page tag) depending on type of traffic source: from utm_campain or non-utm_campain

So, I found the decision: add_action( ‘the_post’, ‘campaign_remove_nextpage’, 99); function campaign_remove_nextpage ( $post ) { if (($_GET[‘utm_campaign’]== ‘Facebook’ || $_GET[‘utm_campaign’]== ‘Twitter’) && (false !== strpos( $post->post_content, ‘<!–nextpage–>’ )) ) { } else { $totalArticlesPages = substr_count($post->post_content, ‘<!–nextpage–>’); // Google: not paginated // Direct: not paginated // Camp: paginated // Reset the global $pages: $GLOBALS[‘pages’] = … Read more

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