Customize Login Expiration Time
By default, the user connection is automatically maintained 3 days. After that time, user has to reconnect. You can use the wpak_auth_connection_expiration_time hook to customize this expiration time in a .php file…
By default, the user connection is automatically maintained 3 days. After that time, user has to reconnect. You can use the wpak_auth_connection_expiration_time hook to customize this expiration time in a .php file…
Post List components query can be customized using the wpak_posts_list_query_args filter hook. Internally, WP-AppKit Post List components’ queries are WP_Query objects. So basically, all customization that can be done on WP_Query objects…
Category To define a custom template (archive-my-category.html) for a given category (slug my-category):
1 2 3 4 5 6 7 |
//In your WP-AppKit theme's functions.js App.filter( 'template', function( template, current_screen ) { if ( TemplateTags.isCategory( 'my-category', current_screen ) ) { template = 'archive-my-category'; //Don't need .html here. } return template; } ); |
Custom Post Type To define a custom single template (single-my-post-type.html) for a given post type (post…
Each template has a pre-defined set of variables passed to it by core. You can also pass your own custom params (variables or functions) to templates by using the template-args…
Add comment’s author email
1 2 3 4 5 6 7 8 |
//In a php file created in your WP-AppKit theme's "php" folder: function add_comment_author_email( $comment_data, $comment_data_raw, $post_id ) { $comment_data['author_email'] = $comment_data_raw['comment_author_email']; return $comment_data; } add_filter( 'wpak_comments_data', 'add_comment_author_email', 10, 3 ); |
Then in your comments.html template:
1 2 3 |
<p> My author email: <%= comment.author_email %> </p> |
Add comment’s parent ID
1 2 3 4 5 6 7 8 |
//In a php file created in your WP-AppKit theme's "php" folder: function add_comment_parent_id( $comment_data, $comment_data_raw, $post_id ) { $comment_data['parent_id'] = $comment_data_raw['comment_parent']; return $comment_data; } add_filter( 'wpak_comments_data', 'add_comment_parent_id', 10, 3 ); |
To Know More Here is the section of the doc concerning the comments.html template
Post Metadata To add a meta (stored as a WordPress post meta, here a meta called pdf) to your post data (in a variable called pdf_url):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php // In a PHP file created under your theme's 'php' folder function add_meta_to_my_app_posts ( $post_data, $post, $component ) { //Standard WordPress post meta: $post_data['pdf_url'] = get_post_meta( $post->ID, 'pdf', true ); //Advanced Custom field meta example: $post_data['my_acf_meta'] = get_field( 'my_acf_meta' ); //Post ID not necessary here return $post_data ; } add_filter( 'wpak_post_data', 'add_meta_to_my_app_posts', 10, 3); |
Then, on app side, to…