{"id":37003827,"url":"https://github.com/versusbassz/wp-batcher","last_synced_at":"2026-01-14T00:35:28.276Z","repository":{"id":57077561,"uuid":"412571852","full_name":"versusbassz/wp-batcher","owner":"versusbassz","description":"Iterate over thousands of posts/users/etc in WordPress without getting OOM and writing boilerplate code","archived":true,"fork":false,"pushed_at":"2022-05-03T20:11:48.000Z","size":70,"stargazers_count":10,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-20T02:23:56.702Z","etag":null,"topics":["iterator","library","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/versusbassz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-01T18:07:33.000Z","updated_at":"2023-02-10T15:16:25.000Z","dependencies_parsed_at":"2022-08-24T12:51:09.083Z","dependency_job_id":null,"html_url":"https://github.com/versusbassz/wp-batcher","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/versusbassz/wp-batcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/versusbassz%2Fwp-batcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/versusbassz%2Fwp-batcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/versusbassz%2Fwp-batcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/versusbassz%2Fwp-batcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/versusbassz","download_url":"https://codeload.github.com/versusbassz/wp-batcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/versusbassz%2Fwp-batcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iterator","library","wordpress"],"created_at":"2026-01-14T00:35:27.504Z","updated_at":"2026-01-14T00:35:28.256Z","avatar_url":"https://github.com/versusbassz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP-Batcher\n\nIf you need to change many items of the same type (posts, users, etc.) in WordPress \n(with possible Out-of-Memory result) \nthis library helps you to write less code and avoid OOM.\n\n## Installation\n```shell\ncomposer require versusbassz/wp-batcher 0.1.*\n```\n\n## How to use\nImagine you have 100000 posts in a database, and you need to iterate over them and change somehow.\n\nOf course, you can't just use `get_posts( [ 'nopaging' =\u003e true ] )`, \nbecause you'll get `Fatal error: memory limit has been exceeded bla bla bla... `.  \n\nSo to do the job you need to handle you posts consequentially chunk by chunk (e.g. 100 posts at a time).\n\nThe example of code without using the library:\n\n```php\n$paged = 1;\n\nwp_suspend_cache_addition( true );\n\nwhile ( true ) {\n\t$items = get_posts( [\n\t\t'posts_per_page' =\u003e 100,\n\t\t'paged' =\u003e $paged,\n\t\t'orderby' =\u003e 'ID',\n\t\t'order' =\u003e 'ASC',\n\t] );\n\n\tif ( ! count( $items ) ) {\n\t\tbreak;\n\t}\n\n\tforeach ( $items as $item ) {\n\t\t// Payload\n\t}\n\n\t++$paged;\n}\n\nwp_suspend_cache_addition( false );\n```\n\nWith using the library the code above turns into to:\n\n```php\nuse \\Versusbassz\\WpBatcher\\WpBatcher;\n\n$iterator = WpBatcher::get_posts();\n\nforeach ( $iterator as $item ) {\n\t// Payload\n}\n```\nAnd the library does more than just `wp_suspend_cache_addition()` under the hood.\n\n## Documentation\nSee [Wiki](https://github.com/versusbassz/wp-batcher/wiki)\n\n## Compatibility\n- PHP \u003e= 5.6 (the target version is a version [required by WordPress](https://wordpress.org/about/requirements/))\n- WordPress 5.7+\n\n## Versioning and stability\nThe project follows https://semver.org/\n\n## License\nThe license of the project is GPL v2 (or later)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversusbassz%2Fwp-batcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fversusbassz%2Fwp-batcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversusbassz%2Fwp-batcher/lists"}