How to fetch posts that are stored in the different table than (default) wp_posts?

Don’t hack the Core. There are filters in WP_Query that should more than suffice to include your table, if your SQL and regex are good enough. posts_distinct – Alters SQL ‘DISTINCTROW’ clause to the query that returns the post array. posts_groupby – Alters SQL ‘GROUP BY’ clause of the query that returns the post array. … Read more

Limit number of posts in WP_query per month

WP_Query is not going to be able to perform a query of the complexity required to do this in one shot. What it would take to pick 10 from one month, ten form another, then 5 from another, then 3, then 1 like that is a number of UNIONs and WP_Query can’t do that. You … Read more

WP_Query loop doen’t work with my custom taxonomy

Your taxonomy and term arguments are incorrect. The preferred method is via tax_query $args = array( // … other args ‘tax_query’ => array( array( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘slug’, ‘terms’ => $term->name ) ) ); Please see WP_Query for all valid arguments and their correct formatting.

Phpmyadmin – post editing

Mysql allows you to run queries that apply to all post, see example : UPDATE wp_posts SET POST_CONTENT = replace(POST_CONTENT, ‘<a href=”http://mysite.com/my_link”>mylink</a>’, ”); This code allows you to delete <a href=”http://mysite.com/my_link”>mylink</a>on all posts. But in your case I doubt all links are the same so you need a pattern. Perhaps it can be done with … Read more

Remove from array in WP_Query loop

This is happening because you are re-initializing the phrases array on each iteration. Define that array outside the loop and this code will work. <?php $frontAgrs = array( ‘post_type’ => ‘page’, ‘tag’ => ‘word’, ‘order’ => ‘ASC’ ); $frontLoop = new WP_Query($frontAgrs); /*—-Phrase————-*/ $phrases = array(‘Hello Sailor’,’Acid Test’,’Bear Garden’,’Botch A Job’,’Dark Horse’, ‘In The Red’,’Man … Read more

Added Date Filter To Popular Posts Query

For creating a date filter you can use // Create a new filtering function that will add our where clause to the query function filter_where( $where=”” ) { // posts in the last 7 days $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-7 days’)) . “‘”; return $where; } add_filter( ‘posts_where’, ‘filter_where’ ); … Read more