# Template Tags DJ Press provides a rich set of template tags to help you build your blog templates. These tags allow you to retrieve and display data from your blog, create navigation menus, format dates, and more. ## Loading Template Tags To use any of the following tags, you must load the `djpress_tags` in your template file: ```django {% load djpress_tags %} ``` ## Tag Categories The template tags in DJ Press are organised into several functional categories: 1. **Data Access Tags** - Tags that start with `get_` retrieve data from the database without any HTML formatting 2. **Display Tags** - Format and display data with appropriate HTML (e.g., `site_title_link`, `blog_categories`) 3. **Post Content Tags** - Handle rendering post content, titles, dates, etc. (e.g., `post_title`, `post_content`) 4. **Navigation Tags** - Generate navigation elements like menus (e.g., `site_pages_list`, `blog_categories`) 5. **Utility Tags** - Additional helper tags for common operations ## Table of Contents - [Data Access Tags](#data-access-tags) - [Display Tags](#display-tags) - [Post Content Tags](#post-content-tags) - [Navigation Tags](#navigation-tags) - [Utility Tags](#utility-tags) ## Data Access Tags These tags retrieve data from your blog without adding any HTML formatting. They're useful when you want to access data but apply your own custom formatting. ### get_posts Returns all published posts as a queryset. Use this tag to access all published blog posts in your templates. **Returns:** queryset of all published posts. > **Related Topics:** See [url_structure.md](url_structure.md) for URL patterns and [themes.md](themes.md) for how to > use posts in your theme. #### get_posts Example This is useful for building an index page with all posts: ```django {% get_posts as all_posts %} {% for post in all_posts %}
This is the full content of the post...
This is the truncated content of the post...
Continue reading...No posts to display.
{% endif %} ``` ### category_title Return the title of a category from the current context. **Returns:** string or HTML-formatted string with the category title. #### category_title Parameters - `outer` (optional): The outer HTML tag for the category. Allowed values: "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "span". - `outer_class` (optional): The CSS class(es) for the outer tag. - `pre_text` (optional): The text to prepend to the category title. - `post_text` (optional): The text to append to the category title. #### category_title Examples ```django {% category_title outer="h1" outer_class="category-title" pre_text="Category: " %} ``` This will output: ```html