Post query – show posts from specified day and month and whole years

You can use WP_Date_Query in conjunction with WP_Query to accomplish this. $query = new \WP_Query( array( ‘posts_per_page’ => 5, ‘date_query’ => array( array( ‘day’ => date( ‘j’, current_time( ‘timestamp’ ) ), ‘month’ => date( ‘n’, current_time( ‘timestamp’ ) ), ‘before’ => ‘this year’ ) ) ) ); if ( $query->have_posts() ) : while ( $query->have_posts() … Read more

How to correctly pass values to wpdb->prepare()?

I’ve found an answer by myself.. (sample code) $args_array = array($post_type); $term_slugs = array(‘foto’, ‘video’); // create a string like ‘%s, %s’ ecc $placeholders = implode(‘, ‘, array_fill(0, count($term_slugs), “%s”)); $term_query = “t.slug IN ($placeholders) “; $args_array = array_merge($args_array, $term_slugs); $ids = $wpdb->get_results($wpdb->prepare(” SELECT m.meta_value FROM ” . $wpdb->prefix . “posts p INNER JOIN ” … Read more

Multiple choice in a custom taxonomy

To display multiple authors, loop through the array of authors: function show_product_autor(){ $authors = wp_get_post_terms( get_the_ID(), ‘autor’ ); foreach($authors as $author) { $authorTeamPg = get_page_by_title( $author->name, ‘OBJECT’, ‘team’ ); $authorTeamPgLink = get_permalink( $authorTeamPg->ID); echo “<b>AUTOR: </b><a href=”https://wordpress.stackexchange.com/questions/289422/{$authorTeamPgLink}”>{$author->name}</a>”,'<br />’; } } To handle editors, the simplest solution IMO would be to make the taxonomy heirarchical and … Read more

Change searched term

The pre_get_posts filter is the right place to go. You can check if you are on a search query, and alter it the way you want. Here’s an example: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { // Check if we are on a search page if ($query->is_search) { // Get the search … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)