I would recommend using WordPress function calls to set up your terms, instead of SQL. This is assuming you’ve already registered a custom taxonomy called job_listing_region.
// Add this to your theme's functions.php
function convert_meta_to_term() {
global $wpdb;
$meta_query = $wpdb->get_results("
SELECT *
FROM $wpdb->postmeta
WHERE meta_key = 'job_listing_region'
");
foreach ($meta_query as $meta) {
// Append new terms for each post
wp_set_object_terms($meta->post_id, $meta->meta_value, 'job_listing_region', true);
}
}
add_action('wp_ajax_convert_meta_to_term', 'convert_meta_to_term');
Now you can call this function by going to the URL http://your-blog.tld/wp-admin/admin-ajax.php?action=convert_meta_to_term
.
Related Posts:
- Using wp_query is it possible to orderby taxonomy?
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- Custom Taxonomy and Tax_Query
- Using WordPress to make a “Product Search” type navigation drilldown
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- display posts with same taxonomy term
- Including all terms in wordpress tax_query
- How to get first post in a category of a custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- wp query with multiple taxonomy?
- wp_query orderby title and meta key value (WP3.1)
- On Taxonomy Template page, want to add Post_Type
- Page queried instead of a custom taxonomy
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- The next_posts_link() show me a aditional page in blank
- Help with a query not working with custom taxonomy
- Adding session variable and/or cookie based on user-selected input
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Advanced Tax Query
- why do drafts return as part of wp_query?
- Improving WP_Query performance for multiple taxonomies
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Advanced Query Logic With Multiple Taxonomies
- How do I Use Multiple Loops with WP_Query?
- cannot get multiple loops using tax_query
- Display all posts for taxonomy term across multiple custom post types
- Selecting all posts from the children of a particular parent taxonomy
- Hiding taxonomies with no children WP_Query & tax_query
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- Set tax_query conditionally with new WP_Query
- querying posts by custom taxonomy terms right from a querystring based URL
- Query custom taxonomy by term id?
- When filtering query on custom taxonomy; main menu dissapears
- Exclude taxonomy term from all loops, but having it on widget
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- Problem with wordpress pagination
- How to do a particular wp_query taxonomy search
- Wp_query…a type of term a different div
- check if a taxnomy queried in $wp_query?
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- WP_Query tax_query – Show results if child has parent X
- Query custom taxonomy for category including children
- Proper way to create taxonomy queries
- how to use tax_query to apply both terms or one if one is empty
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- Run next query based on first query’s term
- Get the original menu item name string instead of the label
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Order posts with custom taxonomy array
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Custom Taxonomy + JQuery Tabs
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to query posts that are not related to any term of a taxonomy?
- Using wp_query is it possible to orderby taxonomy?
- How to limit posts to 1 from each term with tax_query?
- Loop posts without any taxonomy
- get_terms() returns an empty array
- Using a loop to display terms associated with a post
- Taxonomy page template changing when using query variables
- How to add autocomplete to custom taxonomy for CPT
- List subcategory on taxonomy term page
- Using wp_list_categories to show more than one custom taxonomy
- Show all posts without a custom taxonomy
- Order posts by taxonomy count
- How do I taxonomy terms based on terms they are used alongside?
- How do I list the pages of a custom taxonomy?
- Why does a new taxonomy term get created when I assign an existing term to a post?
- Add Image Uploader In Admin Panel
- How do I create a permalink structure with 2 taxonomies
- How to use multiple archive templates for a taxonomy?
- Clicking Add New button for custom taxonomy only moves element
- get all posts associated with a custom taxonomy
- get_term_link not working
- Hide terms if they aren’t the same as the current term
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Change the full permalink (URL) of a single post by connecting it to a specific page
- Add A CSS Class To A Menu Item When A Custom Taxonomy Term is Present On Single Post
- list all post who have mutual taxonomy as current taxonomy!
- Hierarchical taxonomies in permalink cause 404 for sub term archive
- Output slugs to use as class names for every taxonomy a post is attached to
- I cannot get tax_query in get_posts() to work with custom taxonomy
- Query pulling all taxonomies, not one I am specifying
- Display taxonomy posts
- How to get name of custom taxonomy
- How to save custom taxonomy archive as a page template?
- Post Class for Custom Taxonomy Error
- How do I deliver posts based on user geolocation
- Get Posts with matching lowest taxonomies
- Select Custom Taxonomy from Theme Options
- Remove Tag Cloud Words from Custom Taxonomy