How to Display Posts on a Tag Archive Page Based on Custom Field(term meta) Values in WordPress?

Use this- function custom_tag_archive_query( $query ) { if ( is_tag() && $query->is_main_query() && !is_admin() ) { $tag = get_queried_object(); $tag_name = $tag->name; $similar_names = get_term_meta( $tag->term_id, ‘similar_names’, true ); $similar_names_array = explode( ‘,’, $similar_names ); $similar_names_array = array_map( ‘trim’, $similar_names_array ); $similar_names_array[] = $tag_name; // include the tag name itself in the search terms $meta_query … Read more

How can I incldue a “private” post type in a loop for public users?

Figured it out, it was simpler than I expected. /** * Include catalog posts in archives, even though they’re not “public” * * @param WP_Query $query * @return WP_Query */ function wpse415668_catalog_posts_in_archives(WP_Query $query): WP_Query { if (! $query->is_admin() && $query->is_main_query() && $query->is_tax(“catalog_category”)) { $query->set(“post_type”, “catalog”); } return $query; } add_filter(“pre_get_posts”, “wpse415668_catalog_posts_in_archives”);

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