New answers tagged

0

Found the error: $args = array( "posts_per_page" => 12, "paged" => $paged, "post_type" => array( "event", "post" ) , "post_status" => "publish", "meta_key" => "_thumbnail_id", 'meta_query' => array( 'relation' => 'OR', array( ...


0

The most probable route I will take with this is to run a script that would add the desired custom field to the posts which does not have the custom field assigned. You can try the following: (NOTE: This is untested) add_action( 'wp', function () { $args = [ 'post_type' => 'post', // Set according to needs 'posts_per_page' ...


1

You can get both with an OR meta_query that also checks if the key does not exist: 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_date', 'compare' => 'NOT EXISTS', ), array( 'key' => 'event_date', 'value' => date("Ymd", time()), 'compare' => '>', ), ), ...


3

First, you should always use the WordPress AJAX methods, not a custom function for that. See AJAX in Plugins in the Codex. With that practice in mind, you can set up your request like this. Change the AJAX URL to <?php echo admin_url('admin-ajax.php'); ?> and add the actionyou want WordPress to execute in the next step to your data . ...


0

You can handle this by define DATEDIFF() in SELECT For example: SELECT RECID, DATEDIFF(t1.qr_enddate, NOW()) AS diffORD FROM `mytablw` t1 ORDER BY diffORD ASC; This should work but in your case I strongly recommend to use wordpress default Filter API posts orderby. This filter is applied before a post-retrieving SQL statement is executed. Use it to make ...


0

This is adapted from code someone else wrote, and which I benefitted from too long ago to know where it came from (if the person who originally wrote it is reading this, thanks again). It works for your request: <?php $catPost = get_posts('cat=888&posts_per_page=-1000'); foreach ($catPost as $post) : setup_postdata($post); ?> <a ...


0

Best way i think would be to add an array of read post IDs to the user meta table and use them in the 'post__not_in' Parameter in the pre_get_posts hook. In my mobile right now, so i will edit this answer once i'm at work to insert a code example.



Top 50 recent answers are included