How to display elements of different post types?

I am not sure I understand your conditions but I think you want something like this: $arg = array ( ‘post_type’ => array(‘post’,’placas’), ‘orderby’ => ‘rand’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘firmas’, ‘field’ => ‘slug’, ‘terms’ => array( ‘LG’ ), ‘operator’ => ‘NOT IN’, ), array( ‘taxonomy’ => ‘category’, ‘field’ => … Read more

Category menu that filters out empty categories

I had an error in the above code. $key used in both for loops. Working code for filtering empty product categories out of menu items: function exclude_empty_cat_menu_items( $items, $menu, $args ) { // Get a list of product categories that excludes empty categories $non_empty_categories = get_categories(array(‘taxonomy’ => ‘product_cat’)); // Iterate over the menu items foreach … Read more

widget exclude post by custom field

The meta_query parameter in WP_Query allows you to query posts that don’t have a certain custom field. Furthermore, you can check for multiple custom fields. With two queries in meta_query, you can fetch all posts that either don’t have a custom field, or have it set to 0: ‘meta_query’ => array( ‘relation’ => ‘OR’, array( … Read more

How to exclude one post format from search result?

You could probably do it my modifying the loop through the pre_get_posts hook. function wpse163459_search_exclude_post_format( $query ) { if( $query->is_main_query() && $query->is_search() ) { $tax_query = array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-quote’ ), ‘operator’ => ‘NOT IN’, ) ); $query->set( ‘tax_query’, $tax_query ); } } add_action( ‘pre_get_posts’, ‘wpse163459_search_exclude_post_format’ );

Exclude Tags by Array

You could achieve this with get_terms() and ‘name__like’ => ‘Author:’ argument. See linked documentation. From architecture perspective, however, you probably shouldn’t be (ab)using tags for this. It would make sense to split your authors into custom taxonomy. It would be more clear semantically, as well as easier to deal with in interface and code.

$query->set( ‘post_type’, ‘post’ ); not working

After Milo’s help I found a function where it altered the search query: if( is_search() && empty($_GET[‘post_type’]) && !is_admin() ) { global $wpdb; $query = get_search_query(); $query = $wpdb->esc_like( $query ); $where .= ” OR {$wpdb->posts}.ID IN (“; $where .= “SELECT {$wpdb->postmeta}.post_id “; $where .= “FROM {$wpdb->posts}, {$wpdb->postmeta} “; $where .= “WHERE {$wpdb->posts}.post_type=”page” “;<-page to … Read more

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