get_meta_sql hook is not firing
get_meta_sql hook is not firing
get_meta_sql hook is not firing
Ok, I think your iterations were off… You start the count at 0, so while you have the posts from 1 o 7 in the picture, you’re actually working with 0 to 6. So I re-wrote it with greater than and less than comparisons in the if and elseif conditions. <?php function three_column_sc($atts){ ob_start(); ?> … Read more
The simplest solution is to get all the existing rewrite rules, match the requested URl to one of them, and then convert it into a query. Like so: // Get all the rewrite rules global $wp_rewrite; $url_path = “2020/04/test-post”; // Or “tag/whatever” or “feed/atom” etc // Match the URL against WordPress rewrite rules $rewrite_rules = … Read more
They are all convoluted ways of saying the same thing. Syntax 1 is the least efficient method, purely because it takes longer to type and uses unnecessary IN clauses when a single clause will do. All 3 syntaxes are asking WP for posts that have been assigned to both category 76 and 78 Note that … Read more
Here’s a suggestion using posts_orderby filter and CASE, UNIX_TIMESTAMP and DATEDIFF (that outputs number of days) from MySQL for conditional SQL ordering: add_filter( ‘posts_orderby’, function( $orderby, $q ) use (&$wpdb) { if( ! $q->is_main_query() ) { return $orderby; } return $wpdb->prepare( ‘CASE WHEN DATEDIFF( %i.post_date, NOW() ) <= 14 THEN -UNIX_TIMESTAMP( %i.post_date ) ELSE %i.post_title … Read more
You can use either search parameter of wp_query : Code $args = array(“post_type” => “mytype”, “s” => $title); $query = get_posts( $args ); Or you can get posts based on title throught wpdb class: global $wpdb; $myposts = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM $wpdb->posts WHERE post_title LIKE ‘%s'”, ‘%’. $wpdb->esc_like( $title ) .’%’) ); Than you’ll … Read more
In the function wp_get_post_terms() you can select the taxonomy. the default is post_tag you can change it to category. And in the WP_Query args you need to change the tag__in to category__in. // get the categories $categories = wp_get_post_terms($post->ID, ‘category’); if ($categories) { $categories_ids = array(); foreach($categories as $individual_cat) $categories_ids[] = $individual_cat->term_id; $args=array( ‘category__in’ => … Read more
Warning: Cannot modify header information – headers already sent custom sizes and get_intermediate_image_sizes()
I believe the mistake is using get_query_var( ‘paged’ ): this comes from the main query, not from your custom query. Try this (untested): $current_page = 1; if ( isset( $_GET[‘page’] ) ) { $current_page = absint( $_GET[‘page’] ); } And then replace uses of get_query_var( ‘paged’ ) with $current_page.
This could be caused by a pre_get_posts action that doesn’t have the proper conditions/checks. For example: add_action( ‘pre_get_posts’, function( $query ) : void { if ( is_post_type_archive( ‘tribe_events’ ) ) { $query->set( ‘post_type’, ‘tribe_events’ ); } } ); Likewise if this was a page template and not a post archive they might have this in … Read more