{"id":19215547,"url":"https://github.com/alwaysblank/plumbing-templates","last_synced_at":"2025-05-12T23:29:05.678Z","repository":{"id":30522552,"uuid":"125239102","full_name":"alwaysblank/plumbing-templates","owner":"alwaysblank","description":"👩‍🔧 Custom directories for custom templates!","archived":false,"fork":false,"pushed_at":"2021-10-31T19:49:14.000Z","size":39,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-18T02:23:02.681Z","etag":null,"topics":["hacktoberfest","templates","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alwaysblank.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-14T16:06:09.000Z","updated_at":"2023-11-29T21:15:30.000Z","dependencies_parsed_at":"2022-08-17T20:21:23.789Z","dependency_job_id":null,"html_url":"https://github.com/alwaysblank/plumbing-templates","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fplumbing-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fplumbing-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fplumbing-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwaysblank%2Fplumbing-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alwaysblank","download_url":"https://codeload.github.com/alwaysblank/plumbing-templates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223835309,"owners_count":17211158,"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","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":["hacktoberfest","templates","wordpress"],"created_at":"2024-11-09T14:14:01.910Z","updated_at":"2024-11-09T14:14:02.529Z","avatar_url":"https://github.com/alwaysblank.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Template 👩‍🔧\n\nThis tool gives you a way to improve the file organization of your [custom page templates](https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use). For Wordpress 4.7+ you can also use templates for other post types.\n\nIt provides reasonable defaults that should work in most situations, but is also heavily configurable. Ships with built-in support for Sage 10. If you'd like to add built-in support for other frameworks with non-standard template organization, please file a PR or issue.\n\n## Usage\n\nFirst, install the package:\n\n```bash\ncomposer require livy/plumbing-templates\n```\n\nThen call the tool like this, somewhere where it'll be run early (i.e. `functions.php`):\n\n```php\nLivy\\Plumbing\\Templates\\register_template_directory('custom-templates');\n```\n\nBy default, the package assumes you're changing the template for the `page` post type, but you can specify _any_ post type by passing a second parameter:\n\n```php\n// Define templates for the `event` post type:\nLivy\\Plumbing\\Templates\\register_template_directory('event-templates', 'event');\n```\n\nUsually, you'll want to wrap this in an action call to make sure it runs early enough, i.e.:\n\n```php\nadd_action('init', function () {\n    Livy\\Plumbing\\Templates\\register_template_directory('event-templates', 'event');\n});\n```\n\n### Advanced Usage\n\nThis package has a number of other options that allow you to customize its behavior. You can use the project's filters to do this, but it may be easier to pass your arguments all at once. To do this, use `setup_template_location()` instead of `register_template_directory()`:\n\n```php\nLivy\\Plumbing\\Templates\\setup_template_location([\n    'paths' =\u003e [ 'event-templates' ],\n    'post_type' =\u003e 'event',\n]);\n```\n...will have the same effect as the example above.\n\n\u003e The keys `paths` and `post_type` must be defined, or nothing will happen.\n\n#### Options\n\nThe following is a list of all the options this package understands.\n\n- `paths` _array_ - An array of paths (relative to your template root) to search for templates. Default: empty array.\n- `post_type` _string_ - The post type to use these templates for. Default: `page`.\n- `filename` _string_ - Matched against filenames when searching for templates. Can be a string, simple glob (i.e. `*.ext`) or a regular expression. Default: `*.php`.\n- `template_root` _string_ - The template root, which is the directory that all template paths are relative to. It is unlikely you'll need to modify this value. Default: output of [`get_stylesheet_directory()`](https://developer.wordpress.org/reference/functions/get_stylesheet_directory/).\n- `parent_template_root` _string_ - Same as `template_root`, but for templates in a potential parent theme. Ignored if there is no parent theme. It is unlikely you'll need to modify this value. Default: Output of [`get_template_directory()`](https://developer.wordpress.org/reference/functions/get_template_directory()/).\n- `contains` _string_ - A string templates must contain. Can also be a regular expression. Used to identify what files are templates. Default: `Template Name:`.\n- `name_regex` _string_ - A regular expression to get the name of a template from its contents. Default: `/Template Name: ?(.+)/`.\n- `post_type_regex` _string_ - A regular expression to determine if a template applies to a particular post type. `%post_type%` will be replaced with the value of `post_type` option at runtime. Default: `/Template Post Type:.*%post_type%(?=(?:,|$))/m`.\n\n### Acorn and Sage\n\nIf you use the [v10+ of the Sage starter theme](https://github.com/roots/sage) or are using [Acorn](https://github.com/roots/acorn) in some other capacity, you know that your templates are stored in a slightly non-standard location. Fortunately this package [helpfully alters the defaults](https://github.com/alwaysblank/plumbing-templates/blob/56d06ec8ba7fa9dae52a047ef5893bc25ebdd81f/src/filters.php#L11-L17) if it detects that you're using Acorn.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysblank%2Fplumbing-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwaysblank%2Fplumbing-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysblank%2Fplumbing-templates/lists"}