1 | ## loop/
|
---|
2 |
|
---|
3 | This directory contains files that do "the loop". Generally the files in this directory will be included in a file from the _posts/_ or _pages/_ directory, and they will in turn include templates from the _content/_ or _excerpt/_ directories.
|
---|
4 |
|
---|
5 | For example, you might want posts on a search results page to display differently that posts on an archive page. Here is how that page would be built:
|
---|
6 |
|
---|
7 | 1. A page is identified as a search page - Carrington looks for a _posts/search.php_ file and will fall back on a _posts/default.php_ file if none is found.
|
---|
8 | 2. The _posts/search.php_ file will include the header, footer and sidebar - and will also include a call to `cfct_loop()` to include a loop.
|
---|
9 | 3. Since we don't want to show the full posts in search results, the _posts/search.php_ explicitly asks for a file from the _excerpt/_ directory to display the posts in the search results. It will use _excerpt/search.php_ if that file exists, or fall back on _excerpt/default.php_ if the custom file does not exist.
|
---|
10 |
|
---|
11 |
|
---|
12 | ## General Context
|
---|
13 |
|
---|
14 | When choosing a template to use in the General Context, the Carrington engine looks at the type of request is being fulfilled. It will identify the request as the home page, a category archive, and individual post, etc.
|
---|
15 |
|
---|
16 | There is additional checking done for single post requests. All options in the Content Context are supported here with a 'single-' prefix added to the file. See specifics below.
|
---|
17 |
|
---|
18 | A "default" template is required, and will be used when there are no other templates that match a given comment. This could be because no other templates have been created, or because the comment in question doesn't match the templates that are available.
|
---|
19 |
|
---|
20 | By default, conditions are checked in this order:
|
---|
21 |
|
---|
22 | 1. author
|
---|
23 | 2. role
|
---|
24 | 3. category
|
---|
25 | 4. tag
|
---|
26 | 5. single
|
---|
27 | 6. default (home, search, archivem 404, etc.)
|
---|
28 |
|
---|
29 | This can be altered using the `cfct_general_match_order` hook.
|
---|
30 |
|
---|
31 |
|
---|
32 | ### Supported Templates (General Context)
|
---|
33 |
|
---|
34 | - *{dirname}-default.php* (or default.php) - Used when there are no other templates that match for a given page/post.
|
---|
35 | - *archive.php* - Used for date archives or if there are no specific category, author or tag templates.
|
---|
36 | - *author.php* - Used for author archive lists.
|
---|
37 | - *author-{username}.php* - Used when the post/page is authored by a specific user. For example, a template with a file name of _author-jsmith.php_ would be used for a post/page by user _jsmith_. Any WordPress username can take the place of {username} in the file name.
|
---|
38 | - *category.php* - Used for category archive lists.
|
---|
39 | - *cat-{slug}.php* - Used fr displaying a given category. The category is matched by the "slug" - for example a post in category "General" (with a category slug of "general") could use a template of _cat-general.php_.
|
---|
40 | - *home.php* - Used when on the home page.
|
---|
41 | - *page.php* - Used for pages that do not match any other contextual templates.
|
---|
42 | - *role-{rolename}.php
|
---|
43 | - *search.php* - Used when displaying search results.
|
---|
44 | - *single.php* - Used for single post pages.
|
---|
45 | - *single-{content context filenames}.php* - Used for single post pages.
|
---|
46 | - *tag.php* - Used for tag archive lists.
|
---|
47 | - *tag-{slug}.php* - Used for displaying a given tag. The tag is matched by the "slug" - for example a post in tag "News" (with a tag slug of "news") could use a template of _tag-news.php_.
|
---|
48 |
|
---|