$category_in = array();
foreach($topicsofinterest as $topicofinterest){
//Chaneg 'category' to the taxonomy name.
$term = get_term_by( 'name', $topicofinterest, 'category');
$category_in[] = $term->term_id;
}
Just curious, why don’t you store the category ID instead of category name in user meta?
Related Posts:
- Display Featured Post by Categories and Avoid duplicated posts
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- How to echo woocommerce category name
- How to get posts by category and by choosing a taxonomy term?
- get_the_terms has strange result since version 6.0
- How to use the Term Object from a custom select field in a query
- Category Archive not working for pages
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2
- WordPress Custom Search Form Displaying Unexpected Results
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- How to add custom meta to ‘pre_get_terms’?
- Get Child Category only
- wp_query is showing posts from other categories
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- WP_Query Taxonomy categories filtering
- Hide products in uncategorized category from search results
- How to load a script code only in posts?
- Get posts in taxonomy randomly
- Loop posts based on permalink term
- How to display a list of posts in same child category as current post
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- WP Query – filtering terms with regex
- How to exclude a category name from showing?
- Loop categories by recent post
- How order posts from category by date and comment count?
- Get the child category ID of current category
- Related Posts Excluding Certain Categories
- Getting the permalink to the latest post from a category
- What is wrong with my WP_Query Arguments?
- relation OR instead of AND – Filtered term ID’s in loop
- Don’t repeat posts from children in parent taxonomy query
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- Show multiple tax_query from 2 or more post_type in a single code
- Custom taxonomy in WP_Query not working
- Can’t get term id for category archive
- How to make a post with certain taxonomy term display first before other post with only one query?
- Post incorrectly excluded when using “category__in”?
- Related posts by current posts child category
- Filter sub-category from checkbox form
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Filter products on category AND tag
- Strange behaviour of hierarchical taxonomy archive
- adding pagination to a foreach loop in wordpress
- How can I order a post query’s results based on the number of matching taxonomy terms?
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- Only show tag with the same id as the post
- query hook parse_tax_query function takes no effect
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- tax_query not working on custom post type
- Save queried result into database
- 3 posts from each existing category on one page
- How to display the category dropdown auto search list when key press?
- Categories In English version showing not canonical URL, instead shows query search result
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- wp_query with meta_query and tax_query
- What code to use in an array to call the current sub-category?
- Get categories within specific term
- Related categories order posts by category
- WP_Query paginate with one term per page?
- WordPress – Form does not filter the results of taxonomies
- How to show specify category template for both parent and child category
- Pagination for Category does not work
- Exclude parent categories from recent posts list
- Display All Top Child Categories / Taxonomy
- Query post by Category and custom file (ACF)
- Show one post of each custom taxonomy
- Check the product in the cart from which category is and show message
- WP_Query showing all posts, except from category X, unless it’s also in Y
- How to break up output of posts for different terms on same page?
- Single query for multiple categories
- Page with Category Returning 1
- Custom category page with taxonomy filters
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- Display 3 levels of categories on page
- Filtering ‘Featured’ posts from a batch of category IDs
- Show posts from categories instead of tags
- Multiple values in WP_Query : category__and
- taxquery taxonomy get terms
- pages shortcode filtering by category
- How to exclude posts by ID within a category/archive loop
- How to show terms from another taxonomy
- I have 3 categories, i want to display on a loop the last 3 of every category
- How to define a custom hierarchy for terms?
- Adding Category in WP_Query Not Working
- Taxonomy Terms That Don’t Exist Display Results
- display all posts from category with and without terms in chronological order
- Help displaying related categories
- Pull posts from all categories if quantity is not met?
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- How can I get all the posts that are related with a specific taxonomy term?
- Show full category tree for a year with all post titles?
- Custom taxonomy and query multi conditions
- WP Query with sticky posts and tax_query
- Retrieving category pages from subcategory returns empty sets
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- query.php – multiple is_category functions