Gutenberg: Covering All Features of Template Tags in Full Site Editing (FSE)

Created on 29 May 2020  ·  5Comments  ·  Source: WordPress/gutenberg

Covering All Features of Template Tags in Full Site Editing (FSE)

What are template tags?

Template tags are PHP functions used in traditional WordPress template files to display content from the database dynamically. For example, the the_author() tag prints the name of the current author. They are grouped by their "category," which is a loose mapping to the entity they refer to.

Some template tags are also compositions of a set of template tags.

How this relates to FSE.

We need to make sure that we have all the necessary blocks in place to accomplish everything possible in traditional templates using template tags. This issue aims to track our progress towards this goal and to surface areas where we lack functionality and require contributions.

Tracking Tables

Below we track all template tags alongside their block equivalent, if we need one (N/A otherwise), whether the development has started, and whether the current state of development matches or exceeds all the functionality provided by the tag.

Note that this list is just an educated guess. The idea is for everyone in the community, especially those very familiar with traditional theme development, to contribute to this list. There might be things we are missing. There might be things we could lose.

Also, note that some of these blocks could be split up into different blocks if the scope of their functionality creeps too much or people see a benefit in having more fine-grained control. For example, the Post Comments block could use a mechanism like the Query Loop block's to build a template for comments using Comment Author, Comment Date, and Comment Content blocks.

_Template Tags Reference: https://codex.wordpress.org/Template_Tags_

General

| Template Tag | Block Equivalent | Started | Completed |
| ----------------------------- | ---------------- | --------------------- | --------------------- |
| get_header() | Template Part | :white_check_mark: | :black_square_button: |
| get_footer() | Template Part | :white_check_mark: | :black_square_button: |
| get_sidebar() | Template Part | :white_check_mark: | :black_square_button: |
| get_template_part() | Template Part | :white_check_mark: | :black_square_button: |
| get_search_form() | Search | :white_check_mark: | :black_square_button: |
| wp_loginout() | Authentication | :black_square_button: | :black_square_button: |
| wp_logout_url() | Authentication | :black_square_button: | :black_square_button: |
| wp_login_url() | Authentication | :black_square_button: | :black_square_button: |
| wp_login_form() | Authentication | :black_square_button: | :black_square_button: |
| wp_lostpassword_url() | Authentication | :black_square_button: | :black_square_button: |
| wp_register() | Authentication | :black_square_button: | :black_square_button: |
| wp_meta() | N/A | N/A | N/A |
| bloginfo() | N/A | N/A | N/A |
| get_bloginfo() | N/A | N/A | N/A |
| get_current_blog_id() | N/A | N/A | N/A |
| wp_title() | N/A | N/A | N/A |
| single_post_title() | Post Title | :white_check_mark: | :black_square_button: |
| post_type_archive_title() | Query Title | :black_square_button: | :black_square_button: |
| single_cat_title() | Query Title | :black_square_button: | :black_square_button: |
| single_tag_title() | Query Title | :black_square_button: | :black_square_button: |
| single_term_title() | Query Title | :black_square_button: | :black_square_button: |
| single_month_title() | Query Title | :black_square_button: | :black_square_button: |
| get_archives_link() | Navigation | :white_check_mark: | :black_square_button: |
| wp_get_archives() | Navigation | :white_check_mark: | :black_square_button: |
| calendar_week_mod() | Calendar | :black_square_button: | :black_square_button: |
| get_calendar() | Calendar | :black_square_button: | :black_square_button: |
| delete_get_calendar_cache() | N/A | N/A | N/A |
| allowed_tags() | N/A | N/A | N/A |
| wp_ajaxurl() | N/A | N/A | N/A |
| wp_enqueue_script() | N/A | N/A | N/A |

Author

| Template Tag | Block Equivalent | Started | Completed |
| ------------------------- | ---------------- | ------------------ | --------------------- |
| the_author() | Post Author | :white_check_mark: | :black_square_button: |
| get_the_author() | Post Author | :white_check_mark: | :black_square_button: |
| the_author_link() | Post Author | :white_check_mark: | :black_square_button: |
| get_the_author_link() | Post Author | :white_check_mark: | :black_square_button: |
| the_author_meta() | Post Author | :white_check_mark: | :black_square_button: |
| the_author_posts() | Post Author | :white_check_mark: | :black_square_button: |
| the_author_posts_link() | Post Author | :white_check_mark: | :black_square_button: |
| wp_dropdown_users() | Post Author | :white_check_mark: | :black_square_button: |
| wp_list_authors() | Post Author | :white_check_mark: | :black_square_button: |
| get_author_posts_url() | Post Author | :white_check_mark: | :black_square_button: |

Bookmark

| Template Tag | Block Equivalent | Started | Completed |
| ---------------------- | ---------------- | --------------------- | --------------------- |
| wp_list_bookmarks() | Bookmarks | :black_square_button: | :black_square_button: |
| get_bookmark() | Bookmarks | :black_square_button: | :black_square_button: |
| get_bookmark_field() | Bookmarks | :black_square_button: | :black_square_button: |
| get_bookmarks() | Bookmarks | :black_square_button: | :black_square_button: |

Category

| Template Tag | Block Equivalent | Started | Completed |
| -------------------------- | ------------------------ | --------------------- | --------------------- |
| category_description() | Query Description | :black_square_button: | :black_square_button: |
| the_category() | Hierarchichal Taxonomies |✅ | :black_square_button: |
| the_category_rss() | N/A | N/A | N/A |
| wp_dropdown_categories() | Hierarchichal Taxonomies | ✅| :black_square_button: |
| wp_list_categories() | Hierarchichal Taxonomies | ✅| :black_square_button: |
| tag_description() | Query Description | :black_square_button: | :black_square_button: |
| the_tags() | Flat Taxonomies | :black_square_button: | :black_square_button: |
| wp_generate_tag_cloud() | Flat Taxonomies | :black_square_button: | :black_square_button: |
| wp_tag_cloud() | Flat Taxonomies | :black_square_button: | :black_square_button: |
| term_description() | Query Description | :black_square_button: | :black_square_button: |
| get_the_term_list() | Flat Taxonomies | :black_square_button: | :black_square_button: |
| the_terms() | Flat Taxonomies | :black_square_button: | :black_square_button: |
| the_taxonomies() | Flat Taxonomies | :black_square_button: | :black_square_button: |

Comment

| Template Tag | Block Equivalent | Started | Completed |
| ----------------------------- | ------------------- | --------------------- | --------------------- |
| cancel_comment_reply_link() | Post Comments Form | :white_check_mark: | :black_square_button: |
| comment_author_email() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author_email_link() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author_IP() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author_link() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author_rss() | N/A | N/A | N/A |
| comment_author_url() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_author_url_link() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_class() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_date() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_excerpt() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_form_title() | Post Comments Form | :white_check_mark: | :black_square_button: |
| comment_form() | Post Comments Form | :white_check_mark: | :black_square_button: |
| comment_ID() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_id_fields() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_reply_link() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_text() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_text_rss() | N/A | N/A | N/A |
| comment_time() | Post Comments | :white_check_mark: | :black_square_button: |
| comment_type() | Post Comments | :white_check_mark: | :black_square_button: |
| comments_link() | Post Comments Link | :black_square_button: | :black_square_button: |
| comments_number() | Post Comments Count | :white_check_mark: | :black_square_button: |
| comments_popup_link() | Post Comments Link | :black_square_button: | :black_square_button: |
| comments_popup_script() | Post Comments Link | :black_square_button: | :black_square_button: |
| comments_rss_link() | N/A | N/A | N/A |
| get_avatar() | Post Comments | :white_check_mark: | :black_square_button: |
| next_comments_link() | Post Comments | :white_check_mark: | :black_square_button: |
| paginate_comments_links() | Post Comments | :white_check_mark: | :black_square_button: |
| permalink_comments_rss() | N/A | N/A | N/A |
| previous_comments_link() | Post Comments | :white_check_mark: | :black_square_button: |
| wp_list_comments() | Post Comments | :white_check_mark: | :black_square_button: |

Link

| Template Tag | Block Equivalent | Started | Completed |
| ------------------------ | ---------------- | --------------------- | --------------------- |
| the_permalink() | Link | :black_square_button: | :black_square_button: |
| user_trailingslashit() | N/A | :black_square_button: | :black_square_button: |
| permalink_anchor() | Link | :black_square_button: | :black_square_button: |
| get_permalink() | Link | :black_square_button: | :black_square_button: |
| get_post_permalink() | Link | :black_square_button: | :black_square_button: |
| post_permalink() | Link | :black_square_button: | :black_square_button: |
| get_page_link() | Link | :black_square_button: | :black_square_button: |
| get_attachment_link() | Link | :black_square_button: | :black_square_button: |
| wp_shortlink_header() | N/A | N/A | N/A |
| wp_shortlink_wp_head() | N/A | N/A | N/A |
| edit_bookmark_link() | N/A | N/A | N/A |
| edit_comment_link() | Post Comments | :black_square_button: | :black_square_button: |
| edit_post_link() | Link | :black_square_button: | :black_square_button: |
| get_edit_post_link() | Link | :black_square_button: | :black_square_button: |
| get_delete_post_link() | Link | :black_square_button: | :black_square_button: |
| edit_tag_link() | N/A | N/A | N/A |
| get_admin_url() | Link | :black_square_button: | :black_square_button: |
| get_home_url() | Link | :black_square_button: | :black_square_button: |
| get_site_url() | Link | :black_square_button: | :black_square_button: |
| home_url() | Link | :black_square_button: | :black_square_button: |
| site_url() | Link | :black_square_button: | :black_square_button: |
| get_search_link() | Link | :black_square_button: | :black_square_button: |
| get_search_query() | Search | :white_check_mark: | :black_square_button: |
| the_feed_link() | Link | :black_square_button: | :black_square_button: |

Post

| Template Tag | Block Equivalent | Started | Completed |
| ------------------------------- | ---------------- | --------------------- | --------------------- |
| body_class() | N/A | N/A | N/A |
| next_image_link() | N/A | N/A | N/A |
| next_post_link() | Query Pagination | :white_check_mark: | :black_square_button: |
| next_posts_link() | Query Pagination | :white_check_mark: | :black_square_button: |
| post_class() | N/A | N/A | N/A |
| post_password_required() | N/A | N/A | N/A |
| posts_nav_link() | Query Pagination | :white_check_mark: | :black_square_button: |
| previous_image_link() | N/A | N/A | N/A |
| previous_post_link() | Query Pagination | :white_check_mark: | :black_square_button: |
| previous_posts_link() | Query Pagination | :white_check_mark: | :black_square_button: |
| sticky_class() | N/A | N/A | N/A |
| the_content() | Post Content | :white_check_mark: | :black_square_button: |
| the_content_rss() | N/A | N/A | N/A |
| the_excerpt() | Post Excerpt | :white_check_mark: | :black_square_button: |
| the_excerpt_rss() | N/A | N/A | N/A |
| the_ID() | N/A | N/A | N/A |
| the_meta() | Post Field | :black_square_button: | :black_square_button: |
| the_title() | Post Title | :white_check_mark: | :black_square_button: |
| get_the_title() | Post Title | :white_check_mark: | :black_square_button: |
| the_title_attribute() | N/A | N/A | N/A |
| the_title_rss() | N/A | N/A | N/A |
| wp_link_pages() | Query Pagination | :white_check_mark: | :black_square_button: |
| get_attachment_link() | Link | :black_square_button: | :black_square_button: |
| wp_get_attachment_link() | Link | :black_square_button: | :black_square_button: |
| the_attachment_link() | Link | :black_square_button: | :black_square_button: |
| the_search_query() | Search | :white_check_mark: | :black_square_button: |
| is_attachment() | N/A | N/A | N/A |
| wp_attachment_is_image() | N/A | N/A | N/A |
| wp_get_attachment_image() | N/A | N/A | N/A |
| wp_get_attachment_image_src() | N/A | N/A | N/A |
| wp_get_attachment_metadata() | N/A | N/A | N/A |
| get_the_date() | Post Date | :white_check_mark: | :black_square_button: |
| the_date() | Post Date | :white_check_mark: | :black_square_button: |
| the_date_xml() | Post Date | :white_check_mark: | :black_square_button: |
| the_modified_author() | Post Author | :white_check_mark: | :black_square_button: |
| the_modified_date() | Post Date | :white_check_mark: | :black_square_button: |
| the_modified_time() | Post Date | :white_check_mark: | :black_square_button: |
| the_time() | Post Date | :white_check_mark: | :black_square_button: |
| the_shortlink() | Link | :black_square_button: | :black_square_button: |
| wp_get_shortlink() | Link | :black_square_button: | :black_square_button: |

Post Thumbnail

| Template Tag | Block Equivalent | Started | Completed |
| -------------------------- | ------------------- | ------------------ | --------------------- |
| has_post_thumbnail() | Post Featured Image | :white_check_mark: | :black_square_button: |
| get_post_thumbnail_id() | Post Featured Image | :white_check_mark: | :black_square_button: |
| the_post_thumbnail() | Post Featured Image | :white_check_mark: | :black_square_button: |
| get_the_post_thumbnail() | Post Featured Image | :white_check_mark: | :black_square_button: |

Navigation Menu

| Template Tag | Block Equivalent | Started | Completed |
| ---------------------- | ---------------- | ------------------ | --------------------- |
| wp_nav_menu() | Navigation | :white_check_mark: | :black_square_button: |
| walk_nav_menu_tree() | N/A | N/A | N/A |

[Feature] Full Site Editing [Status] In Progress [Type] Overview

Most helpful comment

Posting a summary of our review during a block-based themes meeting:

General:

The loginout things would be useful to add login/logout links, but then again that would probably be most useful as a sub-item in the navigation block.

Bookmark:

These are no longer relevant

Comment:

The only thing missing is RSS, which can be added to comment-authors

Link:

In the context of FSE none of these will be needed... They can be helpers when building more complex PHP code, but on their own they don't mean anything. The only thing that could possibly be added is an "edit-post" link-block

As mentioned by @kjellr: "Most of the “Link” entries could probably just be dynamic links for use in block-based themes. A few might be worth including in the UI for the user to access, but many won’t."

As mentioned by @poena: the post comment link is still used fairly often

Post:

If the post-content block outputs the correct markup with the right ID, using post_class and all the things that dozens of plugins use, we should be OK.

One of the things that troubles us is the_meta(). Themes do all sorts of things with the appearance and functionality of this one... adding icons, styling, links etc.

All 5 comments

Instead of making many blocks for template tags, it would be much better to have dynamic data connecting / mapping to basic blocks:

For example:

  • heading block is connected to post title to display it. So we have full design options from the heading block without duplicating for another post title block. Same can be applied to site title, site description
  • image block is connected to to post thumbnail to display featured image
  • paragraph block is connected to post excerpt

Another good thing is that users can choose which block they want to connect to. For example, users can connect post author to a paragraph block if they want to display it as a normal text or a heading block if they want to display it as a heading tag.

That would be manipulating the sources of attributes through a UI.

I find it hard to imagine a UI where that wouldn't be overwhelmingly technical. Do you have any ideas?

We also have to keep in mind that attribute types are not directly compatible with the sources in question. A lot of these blocks process things before saving them or hide specific options that their sibling "regular" blocks have. For example, the post title, can't and doesn't support all the features of a heading.

@epiqueras Yes, the UI might be the hardest part. I found the Beaver Themer team and Elementor Pro do this quite well. Here is a screenshot from Beaver Themer for reference:

Basically, they have a "toggler" near the input and clicking that shows list of supported sources.

Agree with the attributes/features.

I took a look at the theme we most recently developed, and noted which tags appeared that don't have an existing block in progress development to cover its functionality. Starred what I thought might be most useful to prioritize:

| Template Tag | Usage | 🌟 |
| --- | ----------- | --- |
| the_permalink, get_permalink | used to link the post / page tile, meta, and "continue reading" to the post in reference. | 🌟 |
| bloginfo, get_bloginfo | used to render common site attributes like the name and description in both the markup and its attributes (e.g. in an aria-label). | 🌟 |
| post_password_required | used in logic to determine whether to show post elements like post comments and thumbnail | |
| post_type_archive_title | used to render the archive page title. | 🌟 |
| the_ID | used to specify html id attribute on posts and pages. | |
| post_class | self-evident | 🌟 |
| wp_get_attachment_image, wp_get_attachment_metadata | self-evident | |

Posting a summary of our review during a block-based themes meeting:

General:

The loginout things would be useful to add login/logout links, but then again that would probably be most useful as a sub-item in the navigation block.

Bookmark:

These are no longer relevant

Comment:

The only thing missing is RSS, which can be added to comment-authors

Link:

In the context of FSE none of these will be needed... They can be helpers when building more complex PHP code, but on their own they don't mean anything. The only thing that could possibly be added is an "edit-post" link-block

As mentioned by @kjellr: "Most of the “Link” entries could probably just be dynamic links for use in block-based themes. A few might be worth including in the UI for the user to access, but many won’t."

As mentioned by @poena: the post comment link is still used fairly often

Post:

If the post-content block outputs the correct markup with the right ID, using post_class and all the things that dozens of plugins use, we should be OK.

One of the things that troubles us is the_meta(). Themes do all sorts of things with the appearance and functionality of this one... adding icons, styling, links etc.

Was this page helpful?
0 / 5 - 0 ratings