WordPress to Textpattern theme
October 23, 2018 · View on GitHub
Txp theme structure
Description
Textpattern stores code chunks as pages and forms in its database. Forms allow to customize the output of some Txp tags (functions) such as article, comments, search_input, etc.; they also provide a way to store other custom templates parts, or overriding forms (post formats). which can be output via the output_form tag. Pages are used to include forms and/or static contents.
- template parts are defined through custom forms
- post formats can be defined via custom article forms and used as overidding_forms in the admin Write panel
Default theme filetree
themes
+-- my_theme
| +-- pages
| | +-- archive.txp (Page example)
| | +-- default.txp (default page display)
| | +-- error_default.txp (default error page display)
| | +-- …
| +-- forms
| | +-- article
| | | +-- default.txp (default article display used by the 'article' tag)
| | | +-- article_listing.txp (default article list display used by the 'article' tag)
| | | +-- search_results.txp (default search results display used by the 'search_results' tag)
| | | +-- …
| | +-- comment
| | | +-- comment_form.txp (default comment form display used by the 'comments_form' tag)
| | | +-- comments.txp (default comments display used by the 'comments' tag)
| | | +-- comments_display.txp (default comment display used by the 'comment' tag)
| | | +-- popup_comments.txp (default comments popup display)
| | | +-- …
| | +-- file
| | | +-- files.txp (default file display used by the 'file_download' tag)
| | | +-- …
| | +-- link
| | | +-- plainlinks.txp (default links display used by the 'linklist' tag)
| | | +-- …
| | +-- misc
| | | +-- images.txp (not defined as the default form of any tag)
| | | +-- search_input.txp (default search form display used by the 'search_input' tag)
| | | +-- …
| +-- styles
| | +-- default.css (not defined as the default style of any tag)
| | +-- …
+-- …
Introduction to Txp tags
WP vs Txp tags
WordPress templates contain HTML and PHP.
While Textpattern templates can also contain some PHP code, they are usually mainly composed of HTML and Txp tags.
Textpattern tags are easy to use and make themes really easy to read and modify. You don't even need repeated <?php ?> tags to switch between HTML and PHP.
Conditional contents
WordPress uses has_ and in_ prefixed functions to include conditional contents.
<?php if ( in_category( '3' ) ) : ?>
<div class="post-cat-three">
<?php else : ?>
<div class="post">
<?php endif; ?>
Textpattern use conditional tags prefixed by if_.
<txp:if_category name="3">
<div class="post-cat-three">
<txp:else />
<div class="post">
</txp:if_article>
From the introduction of short-tags in Txp v4.7+, you could even make it shorter.
And in case there is not conditional tag for your need, the recent evaluate tag allows to check any tag output! It also does a lot more…
Tags reference
WP functions to Txp tags [a→z]
_
B
C
comment_author()→comment_name;comment_author_email()→comment_email;comment_date()→comment_time;comment_ID()→comment_id;comments_number()→comments_count;comments_open()→if_comments_allowed;comment_form()→comments_form;comment_text()→comment_message;comment_time()→comment_time;content_url()→page_url.
G
get_bookmark()→link;get_footer()(default file:footer.php) →output_form;get_header()(default file:header.php) →output_form;get_search_form()→search_input(default form:search_input);get_sidebar()(default file:sidebar.php) →output_form;get_template_part()→output_form.
H
has_excerpt()→if_excerpt;has_post_thumbnail()→if_article_image;have_posts()→if_article;have_comments()→if_comments.
I
is_author()→if_author;is_category()→if_category;is_plugin_active()→if_plugin;is_search()→if_search;is_single()→if_article_id;is_singular()→if_individual_article.
L
N
P
S
T
the_author()→author;the_author_posts_link()→author;the_content()→body;the_excerpt()→excerpt;the_feed_link()→feed_link;the_id()→article_id;the_loop()→article;the_modified_time()→modified;the_permalink()→permlink;the_post()→article(default form:default, listform:article_listing);the_post_thumbnail()→article_image;the_search_query()→search_term;the_title()→title;the_time()→posted.
W
wp_get_attachment_image()→article_image;wp_list_authors()→authors;wp_list_bookmarks()→linklist(default form:plainlinks);wp_list_categories()→category_list;wp_list_comments()→comments(default form:comments).