Search query -> Show all pages except certain template

REWORKED ANSWER TO ANSWER THE QUESTION In order to exclude all pages with a certain template, all you need to do is to run a meta_query to exclude all pages with the custom field _wp_page_template set to bedankt. Remember, WordPress saves the template assigned to a page as a hidden custom field called _wp_page_template With … Read more

Get all products which have both product category

Set include_children to false in the tax_query. $args = array( ‘post_type’ => array( ‘product’, ‘product_variation’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘shop’, ‘cat1’ ), ‘include_children’ => false, ‘operator’ => ‘AND’, ) ) ); See https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Getting post data from private page

setup_postdata takes a post object of type \WP_Post, but you’re passing it a WP_Query instead e.g. global $post; setup_postdata( $post ); Thankfully the solution is trivial, when you call the_post, it sets up the current post data for you, so removing that line is all you need to do. The second issue is that WP_Query … Read more

Echo a hierarchical list of post data from custom fields

A little example, based on get_posts and get_post_meta. $locations = get_posts( array(‘post_type’ => ‘locations’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’ ); echo ‘<ul>’; foreach ($locations as $location) { $location_city = get_post_meta($location->ID, ‘city’, true); $location_state = get_post_meta($location->ID, ‘state’, true); $location_address = get_post_meta($location->ID, ‘address’, true); echo ‘<li>’ . $location_city; echo ‘<li>’ . $location_state . ‘</li>’; echo ‘<li>’ … Read more

Get post according to current taxonomy

Try this for WP_Query $args = array( ‘post_type’ => ‘example’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘identite’, ‘field’ => ‘ID’, ‘terms’ => $term->term_id ) ), );// end args OR $args = array( ‘post_type’ => ‘example’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘identite’, ‘field’ => ‘ID’, ‘terms’ => array($term->term_id) ) … Read more

only delete post within query / for each statement (front end)

You should pass in the id of the post you want to delete as an argument of the delete_post() function rather than relying on obtaining it via global $post within the function itself: <?php echo delete_post($section->ID); ?> Then in your delete_post() function you can use the passed-in argument like so: function delete_post($sectionid){ $deletepostlink= add_query_arg( ‘frontend’, … Read more

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