{"id":23,"date":"2009-11-01T22:32:31","date_gmt":"2009-11-01T21:32:31","guid":{"rendered":"http:\/\/wpseek.com\/blog\/?p=23"},"modified":"2022-03-07T09:40:20","modified_gmt":"2022-03-07T08:40:20","slug":"auto-tag-800-posts-with-auto-tags-automatically","status":"publish","type":"post","link":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/","title":{"rendered":"Auto-Tag 800+ posts with &#8220;Auto Tags&#8221; &#8211; automatically"},"content":{"rendered":"<h4>The problem<\/h4>\n<p>How to auto-tag your posts with the plugin &#8220;Auto Tags&#8221; after they&#8217;ve been published already without manually edit and save each post to get them auto-tagged? Additionally, you don&#8217;t have SSH access to your server and the PHP max_execution_time is limited to 30 or 60 seconds so a script&#8217;s runtime would exceed and result in a blank page or fatal error?<!--more--><\/p>\n<h4>The solution<\/h4>\n<p>Put a file auto-tag.php (or whatever you&#8217;d like) in your WP document root and fill it with the following contents:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php\r\nerror_reporting(E_ALL ^ E_NOTICE);\r\nini_set('display_errors', '1');\r\n\r\ndefine('WP_USE_THEMES', false);\r\nrequire('.\/wp-blog-header.php');\r\nglobal $wpdb;\r\n\r\nif( !isset($_GET&#x5B;'offset']) ) {\r\n  $offset = (int)$_GET&#x5B;'offset'];\r\n}\r\n\r\n$all_post_ids = $wpdb-&gt;get_col(&quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_type = 'post'&quot;);\r\n$post_ids = $wpdb-&gt;get_col(&quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_type = 'post' ORDER BY ID ASC LIMIT &quot; . $_GET&#x5B;'offset'] . &quot;,3&quot;);\r\n\r\nif( $_GET&#x5B;'offset'] &gt;= count($all_post_ids) ) {\r\n  die('Done.');\r\n  exit;\r\n}\r\n\r\nforeach( $post_ids as $post_id ) {\r\n  do_action( 'wp_insert_post', $post_id );\r\n}\r\n$offset = $_GET&#x5B;'offset']+3;\r\necho '&lt;meta http-equiv=&quot;refresh&quot; content=&quot;2; url=' . $_SERVER&#x5B;'SCRIPT_NAME'] . '?offset=' . $offset . '&quot;&gt;';\r\n?&gt;<\/pre>\n<h4>What does it do?<\/h4>\n<p>To avoid the script being aborted due to the PHP max_execution_time, the above script auto-tags 3 posts at a time, then automatically reloads the page, auto-tags the next 3 posts and so on. All you have to do is watch the script do the work for you, and get a coffee.<\/p>\n<h4>Requirements<\/h4>\n<ul>\n<li>WordPress 2.0 and above<\/li>\n<li>Plugin <a href=\"http:\/\/wordpress.org\/extend\/plugins\/auto-tag\/\" target=\"_blank\" rel=\"noopener\">Auto-Tags<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The problem How to auto-tag your posts with the plugin &#8220;Auto Tags&#8221; after they&#8217;ve been published already without manually edit and save each post to get them auto-tagged? Additionally, you don&#8217;t have SSH access to your server and the PHP max_execution_time is limited to 30 or 60 seconds so a script&#8217;s runtime would exceed and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,13],"tags":[9,10,12,11],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-wordpress-hacks","category-wordpress-plugin-hacks","tag-auto-tag","tag-auto-tags","tag-max-execution-time","tag-plugin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Auto-Tag 800+ posts with &quot;Auto Tags&quot; - automatically &#8211; wpseek.com \/\/ blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto-Tag 800+ posts with &quot;Auto Tags&quot; - automatically &#8211; wpseek.com \/\/ blog\" \/>\n<meta property=\"og:description\" content=\"The problem How to auto-tag your posts with the plugin &#8220;Auto Tags&#8221; after they&#8217;ve been published already without manually edit and save each post to get them auto-tagged? Additionally, you don&#8217;t have SSH access to your server and the PHP max_execution_time is limited to 30 or 60 seconds so a script&#8217;s runtime would exceed and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/\" \/>\n<meta property=\"og:site_name\" content=\"wpseek.com \/\/ blog\" \/>\n<meta property=\"article:published_time\" content=\"2009-11-01T21:32:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-07T08:40:20+00:00\" \/>\n<meta name=\"author\" content=\"wpseek (admin)\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"wpseek (admin)\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/\"},\"author\":{\"name\":\"wpseek (admin)\",\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#\\\/schema\\\/person\\\/d19081ecaffc56ccc034dbd009ede8eb\"},\"headline\":\"Auto-Tag 800+ posts with &#8220;Auto Tags&#8221; &#8211; automatically\",\"datePublished\":\"2009-11-01T21:32:31+00:00\",\"dateModified\":\"2022-03-07T08:40:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/\"},\"wordCount\":281,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#\\\/schema\\\/person\\\/d19081ecaffc56ccc034dbd009ede8eb\"},\"keywords\":[\"auto tag\",\"auto tags\",\"max execution time\",\"plugin\"],\"articleSection\":[\"WordPress Hacks\",\"WordPress Plugin Hacks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/\",\"url\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/\",\"name\":\"Auto-Tag 800+ posts with \\\"Auto Tags\\\" - automatically &#8211; wpseek.com \\\/\\\/ blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#website\"},\"datePublished\":\"2009-11-01T21:32:31+00:00\",\"dateModified\":\"2022-03-07T08:40:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/2009\\\/auto-tag-800-posts-with-auto-tags-automatically\\\/23\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto-Tag 800+ posts with &#8220;Auto Tags&#8221; &#8211; automatically\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/\",\"name\":\"wpseek.com \\\/\\\/ blog\",\"description\":\"A random blog about WordPress\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#\\\/schema\\\/person\\\/d19081ecaffc56ccc034dbd009ede8eb\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#\\\/schema\\\/person\\\/d19081ecaffc56ccc034dbd009ede8eb\",\"name\":\"wpseek (admin)\",\"logo\":{\"@id\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"http:\\\/\\\/wpseek.com\"],\"url\":\"https:\\\/\\\/wpseek.com\\\/blog\\\/author\\\/wpseek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Auto-Tag 800+ posts with \"Auto Tags\" - automatically &#8211; wpseek.com \/\/ blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/","og_locale":"en_US","og_type":"article","og_title":"Auto-Tag 800+ posts with \"Auto Tags\" - automatically &#8211; wpseek.com \/\/ blog","og_description":"The problem How to auto-tag your posts with the plugin &#8220;Auto Tags&#8221; after they&#8217;ve been published already without manually edit and save each post to get them auto-tagged? Additionally, you don&#8217;t have SSH access to your server and the PHP max_execution_time is limited to 30 or 60 seconds so a script&#8217;s runtime would exceed and [&hellip;]","og_url":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/","og_site_name":"wpseek.com \/\/ blog","article_published_time":"2009-11-01T21:32:31+00:00","article_modified_time":"2022-03-07T08:40:20+00:00","author":"wpseek (admin)","twitter_card":"summary_large_image","twitter_misc":{"Written by":"wpseek (admin)","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/#article","isPartOf":{"@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/"},"author":{"name":"wpseek (admin)","@id":"https:\/\/wpseek.com\/blog\/#\/schema\/person\/d19081ecaffc56ccc034dbd009ede8eb"},"headline":"Auto-Tag 800+ posts with &#8220;Auto Tags&#8221; &#8211; automatically","datePublished":"2009-11-01T21:32:31+00:00","dateModified":"2022-03-07T08:40:20+00:00","mainEntityOfPage":{"@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/"},"wordCount":281,"commentCount":0,"publisher":{"@id":"https:\/\/wpseek.com\/blog\/#\/schema\/person\/d19081ecaffc56ccc034dbd009ede8eb"},"keywords":["auto tag","auto tags","max execution time","plugin"],"articleSection":["WordPress Hacks","WordPress Plugin Hacks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/","url":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/","name":"Auto-Tag 800+ posts with \"Auto Tags\" - automatically &#8211; wpseek.com \/\/ blog","isPartOf":{"@id":"https:\/\/wpseek.com\/blog\/#website"},"datePublished":"2009-11-01T21:32:31+00:00","dateModified":"2022-03-07T08:40:20+00:00","breadcrumb":{"@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpseek.com\/blog\/2009\/auto-tag-800-posts-with-auto-tags-automatically\/23\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpseek.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Auto-Tag 800+ posts with &#8220;Auto Tags&#8221; &#8211; automatically"}]},{"@type":"WebSite","@id":"https:\/\/wpseek.com\/blog\/#website","url":"https:\/\/wpseek.com\/blog\/","name":"wpseek.com \/\/ blog","description":"A random blog about WordPress","publisher":{"@id":"https:\/\/wpseek.com\/blog\/#\/schema\/person\/d19081ecaffc56ccc034dbd009ede8eb"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpseek.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wpseek.com\/blog\/#\/schema\/person\/d19081ecaffc56ccc034dbd009ede8eb","name":"wpseek (admin)","logo":{"@id":"https:\/\/wpseek.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/wpseek.com"],"url":"https:\/\/wpseek.com\/blog\/author\/wpseek\/"}]}},"_links":{"self":[{"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":2,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":12772,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions\/12772"}],"wp:attachment":[{"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpseek.com\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}