{"id":26753184,"url":"https://github.com/benrutlandweb/wpeloquent","last_synced_at":"2026-05-19T14:38:12.035Z","repository":{"id":62497685,"uuid":"293588591","full_name":"BenRutlandWeb/WPEloquent","owner":"BenRutlandWeb","description":"Eloquent models for WordPress","archived":false,"fork":false,"pushed_at":"2020-09-22T18:59:15.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T15:48:08.675Z","etag":null,"topics":["eloquent","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenRutlandWeb.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":"2020-09-07T17:17:01.000Z","updated_at":"2021-03-09T15:28:13.000Z","dependencies_parsed_at":"2022-11-02T09:46:39.688Z","dependency_job_id":null,"html_url":"https://github.com/BenRutlandWeb/WPEloquent","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BenRutlandWeb/WPEloquent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRutlandWeb%2FWPEloquent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRutlandWeb%2FWPEloquent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRutlandWeb%2FWPEloquent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRutlandWeb%2FWPEloquent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenRutlandWeb","download_url":"https://codeload.github.com/BenRutlandWeb/WPEloquent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRutlandWeb%2FWPEloquent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273919931,"owners_count":25191207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["eloquent","wordpress"],"created_at":"2025-03-28T13:18:08.440Z","updated_at":"2026-05-19T14:38:12.005Z","avatar_url":"https://github.com/BenRutlandWeb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WPEloquent\n\nEloquent models for WordPress\n\n## Introduction\n\nWPEloquent uses Laravel's [Eloquent ORM](https://laravel.com/docs/8.x/eloquent)\nto interact with WordPress' database.\n\nWPEloquent comes with the following Models:\n\n- Post\n- Page\n- Attachment\n- PostMeta\n- Term\n- TermMeta\n- User\n- UserMeta\n- Comment\n- CommentMeta\n- Option\n- Taxonomy\n- TermRelationship\n\n---\n\n## Getting started\n\nInstall the brw/wp-eloquent package\n\n```bash\ncomposer require brw/wp-eloquent\n```\n\n_functions.php_\n\n```php\n\u003c?php\n\nuse WPEloquent\\Database;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n// Basic usage\nDatabase::connect();\n\n// Advanced usage\nDatabase::connect(\n    [\n        'driver'    =\u003e 'mysql',\n        'prefix'    =\u003e 'wp_',\n        'host'      =\u003e DB_HOST,\n        'database'  =\u003e DB_NAME,\n        'username'  =\u003e DB_USER,\n        'password'  =\u003e DB_PASSWORD,\n        'port'      =\u003e '3306',\n        'charset'   =\u003e 'utf8',\n        'collation' =\u003e 'utf8_unicode_ci',\n    ]\n);\n```\n\n## The basics\n\nEach model has relationships defined to interact with other models. As an \nexample, the Post model has terms, author, comments and so on.\n\nFull documentation on the Fluent API: [Eloquent ORM](https://laravel.com/docs/8.x/eloquent).\n\n```php\n\u003c?php\n\nuse WPEloquent\\Models\\Post;\n\n$posts = Post::limit(10)-\u003ewhere('post_status', 'publish')-\u003eget();\n\nforeach ($posts as $post) : ?\u003e\n    \u003ch2\u003e\u003c?php echo $post-\u003etitle; ?\u003e\u003c/h2\u003e\n    \u003cp\u003e\u003c?php echo $post-\u003eauthor-\u003eemail; ?\u003e\u003c/p\u003e\n\u003c?php endforeach;\n```\n\n---\n\n## Extending Models\n\nYou can easily extend Models for Custom Post Types, or implement new Models for\ncustom tables.\n\n### Custom Post Type\n\nDefine a new Model. For a custom post type, it's easiest to extend the\nWPEloquent Post model, and change the `$postType` property.\n\n```php\n\u003c?php\n\nuse WPEloquent\\Models\\Post;\n\nclass CustomPostType extends Post\n{\n    /**\n     * The post type for the model.\n     *\n     * @var array|string\n     */\n    $postType = 'custom_post_type';\n}\n```\n\n### Custom Model\n\nTo define a Model for a custom table, extend the WPEloquent Model and set the\n`$table` property to the name of the table. This will be prefixed automatically.\n\n```php\n\u003c?php\n\nuse WPEloquent\\Models\\Model;\n\nclass CustomTable extends Model\n{\n    /**\n     * The table associated with the model.\n     *\n     * @var string\n     */\n    protected $table = 'custom_table';\n}\n```\n\n### TODO\n- [ ] DB facade\n- [ ] Update database connection to use `$wpdb` rather than creating a new connection.\n- [ ] Improve database class to connect with a nicer API\n- [ ] Add more documentation on Model relationships\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrutlandweb%2Fwpeloquent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenrutlandweb%2Fwpeloquent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrutlandweb%2Fwpeloquent/lists"}