You can use WordPress functions to do this and just run it once, a fast example would be.
function wpse_85236_add_photo_field(){
global $post;
$photoquery = new WP_Query('posts_per_page=-1');
while ( $photoquery->have_posts() ) : $photoquery->the_post();
if ( in_category( 'photography' )) {
add_post_meta($post->ID, 'category', 'photography', true);
}
endwhile;
}
add_action( 'init', 'wpse_85236_add_photo_field' );
Remember to remove the function after it runs because you don’t want it to run on every load.
Related Posts:
- Convert custom fields to post categories
- Categories list into registration form
- if in category but only with post meta
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Post meta not working
- Is there a way to save different data when USER interacts with the same POST?
- Order posts by separate menu order for different sub-categories
- Delete old post with new post
- How to display two blog categories as separate sections on one page?
- Hooking into the post editing screen for an existing page only
- Query Posts by Custom Field
- How to make the first post in the loop be styled like a “new / featured” post?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Redirect to another page using contact form 7? [closed]
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- Hide posts belongs to few categories in homepage
- why does wordpress ignore the post args?
- post category in wp_insert_post
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- How to rate a post from Admin Side / Manually?
- How to get subcategories from category slug?
- Remove current category from post but display all others
- How show categories in admin and get that selected to show posts in index
- Customize rel=canonical tag for single blog post
- How to I retrieve the ID from the Posts page?
- Showing categories and subcategories with posts
- Change default category when I publish a post
- store posts_id of category into a varable?
- How to display two random-post sections that are each under their own category
- How can you display all sibling categories to a post?
- Get post ID from a link
- Loop doesn’t exclude the specified category in home page
- Display posts of specific category term
- Create a list of posts with topic headdings
- Add field to user meta table in database when link is clicked
- Widget that shows categories with posts numbers
- How to create a sub post?
- Hide custom metabox value from custom fields
- Post Image not displaying in category view
- How do I show posts from another wordpress installation?
- Get post meta retrieving wrong value
- get posts from Custom Post Type & Category
- Category page when using static front page
- Latest posts by category — how to exclude current post?
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to create a “latest news” page showing a list of posts from blog category
- Edit multiple custom post types while saving a new or edited post
- WordPress bulk category select when publishing post
- Exclude some categories from listing on the current post
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- how to hide empty fields of post category description?
- how can i display my posts alphabetically?
- How to get post with associated categories and tags names instead of ids with rest api?
- Display a mixed list of posts and media
- Migrate posts from category and sub-category via SQL
- Parent category / child category posts
- Posts Missing in Dashboard after update
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- Display post number by category
- Output Post with ACF Fields into other Post
- Saving Post Data in Another Database
- singular posts using archive styling
- Change Post Title For Specific Category
- Display selected categories onto post page
- How to call posts under a specific category on static front page?
- Add two custom fields as a default to the “new post” page.
- Give posts a particular template based on the assigned category
- How to have more than one page for your posts if you have 8 posts but can store max 4 on a page
- Extract wordpress posts content and category content
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- How to get post with slug and exclude categories
- After ajax image is outside the “ tag
- Edit custom fields in posts list
- All categories displays the same posts
- Add multiple meta keys to a post at once
- Having pages after specifying post_type post
- Unable to differentiate between two categories under custom post type on single.php
- WP_Query custom field pass the post id
- In what context should Categories and Tags be used
- Exclude post category in a blog page
- Show posts on front page only
- list posts from two categories on a page – plugin not working
- Retrieving posts by their date and category
- Get latest post from categories
- How to create a playlist for audio associated with posts per category
- Are post, page and category IDs unique to each other?
- Change the background of each post according to the category
- Static pages not working
- Post-Archive like a page in a specific subdirectory
- Programmatically add posts from specific category to menu
- WP_Query of Category Not Showing First Post
- If custom field is empty, use one from a previous post