WP_Query won’t retrieve raw HTML?

WP_Query object contains FULL content of posts/pages retrieved from database. No HTML tags are being removed. Therefore, the following statement in your question: It looks like WP_Query is parsing the HTML and then displaying what is left. is not true. If you use, in your code, the_content() instead of the_excerpt() function, you’ll see that all … Read more

shortcode to show custom post types by category

Here is a part in your code that may cause error: $catlist .= ‘<h2>’.the_title().'</h2>’; Try replacing with $catlist .= ‘<h2>’.get_the_title().'</h2>’; Explanation: the_title() echo the title of the post. But in your case you are using it within a function that will return the value. So you have to use get_the_title() instead. Thanks. Note: also there … Read more

Custom query based on meta key – Reduce three states to two in results?

This can be done by providing a “default” value to the ORDER BY statement. Try adding this before your call new WP_Query($args);: $setDefaultOrderby = function($statement) { return str_replace(‘wp_postmeta.meta_value’, “COALESCE(wp_postmeta.meta_value, ‘false’)”, $statement); }; add_filter(‘posts_orderby’, $setDefaultOrderby); and this after it: remove_filter(‘posts_orderby’, $setDefaultOrderby); Change the ‘false’ with whatever the default value is that you need. I am using … Read more

Reset Popular post query?

If you’re ok resetting it weekly – as in have views start from 0 every Monday – rather than trying to show the most read in the last 7 days, then the simplest change would be to have a different meta key for every week of the year. Then when you query the posts, you … Read more

query offset countdown by 2 each day?

There could be several approaches but here is one, which comes in my mind. Steps with code example: Initially, store the count in Database using Options API like this: update_option(‘offset_count’, 1000); $current_date = date(“d”); update_option(‘last_countdown_date’, $current_date); Before querying the post, retrieve both values from DB, like this: $offset_count = get_option( ‘offset_count’ ); $last_date = get_option( … Read more

Nested tax_query that allows specified categories OR tags, but NOT other categories

I think I figured it out. This query appears to work: $args = array(); if ( isset( $term_ids ) && isset( $category_ids ) ) { $args[‘tax_query’] = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => $omit_category_ids, ‘operator’ => ‘NOT IN’, ), array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ … Read more

Meta Query Array Error 500

In my previous answer (that I’ve deleted..), I suggested using custom SQL queries, which worked for me. However, since it didn’t work (well) for you, let’s try using this function: function get_player_stats( $player_id ) { $apps = 0; // Total appearances. $subs = 0; // Total sub-appearances. $goals = 0; // Total goals. // Get … Read more