-
AuthorPosts
-
April 7, 2020 at 3:26 pm #1201629
Team:
I would like to automatically display author, date and categories in a box left to the blog content area. I am currently doing this manually (not yet the categories, though)…
https://snipboard.io/53l0P9.jpg
… using a simple text box:
https://snipboard.io/P0ZoYB.jpg
Is there a way to automatise this, such that the box displays the author, the publication date and the categories without entering such info manually?
Thanks,
MagnusApril 10, 2020 at 7:59 pm #1202722Hey mbosse99,
The blog posts meta is shown automatically only on blogposts built with the Classic editor, when you build bosts with the Advanced Layout Builder you need to add it manually.
But you can have a look at the solution posted here:
https://kriesi.at/support/topic/post-using-advanced-editor-how-to-insert-post-meta-info-title-date-etc/If you need further assistance please let us know.
Best regards,
VictoriaApril 15, 2020 at 11:20 am #1203924Thanks Victoria:
I figured the following:
for Post Title:
function post_title_shortcode(){ global $post; return get_the_title($post->ID); } add_shortcode( 'sc_post_title', 'post_title_shortcode' );
For Post Date:
function post_date_shortcode(){ global $post; return get_the_date('Y-m-d', $post->ID); } add_shortcode( 'sc_post_date', 'post_date_shortcode' );
For Post Category:
function post_category_shortcode(){ global $post; return get_the_category($post->ID); } add_shortcode( ‘sc_post_category’, ‘post_category_shortcode’ );
Now what would I need for Post Author?
Thanks,
MagnusApril 15, 2020 at 4:41 pm #1204037Hi Magnus,
You need to use the get_the_author() function.
Here are the docs for you:
If you need further assistance please let us know.
Best regards,
VictoriaApril 20, 2020 at 2:42 pm #1205495Hi Victoria:
a bit late but still – success – almost! I now can automatically include post title, date and author into a blog post. What does not work is the category – it always returns ‘Array’ as a display.
Here is the function I used – what is wrong? Note that I might have more than one category for a single post.
function post_category_shortcode(){ global $post; return get_the_category($post->ID); } add_shortcode( 'sc_post_category', 'post_category_shortcode' );
Thanks!
Magnus- This reply was modified 4 years, 7 months ago by mbosse99.
April 21, 2020 at 3:10 pm #1205813Hi Magnus,
Because posts have many categories and they are returned as an array and so have to be treated differently.
You can try using this function instead:
If you need further assistance please let us know.
Best regards,
VictoriaApril 27, 2020 at 11:24 am #1207475Excellent, thanks a lot – that solved it!
April 27, 2020 at 6:29 pm #1207564Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Blog Posts: Automatically display author, date, and categories?’ is closed to new replies.