{"id":2509,"date":"2022-04-07T18:37:23","date_gmt":"2022-04-07T10:37:23","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2509"},"modified":"2022-04-11T14:06:42","modified_gmt":"2022-04-11T06:06:42","slug":"rearrange-astra-post-elements","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/rearrange-astra-post-elements\/","title":{"rendered":"How To Rearrange Astra Post Elements"},"content":{"rendered":"\n
A reader asked how to completely rearrange the post elements in WordPress Astra<\/a>.<\/p>\n\n\n\n They wanted to order it as:<\/p>\n\n\n\n They also wanted the same ordering on both the single posts and in the category pages.<\/p>\n\n\n\n Regardless of whether you want to order your layout in this exact order, there will be some useful information to help you customize your order.<\/p>\n\n\n\n To get the date above the title I used the code:<\/p>\n\n\n\n This connects the display of the date into the relevant post_title_before<\/em> sections.<\/p>\n\n\n\n To display the categories and tags at the bottom I used this code:<\/p>\n\n\n\n To see a full description of this code and what it does, have a look at the tutorial on how to display WordPress categories below the content in Astra<\/a>.<\/p>\n\n\n\n Finally, I hid the date, categories and tags from their default positions, using the Customizer. You can see a full explanation under customizing the Astra post meta<\/a>.<\/p>\n\n\n\n The end result looked like this:<\/p>\n\n\n\nDisplay the date above the post title<\/h2>\n\n\n\n
add_action( 'astra_single_post_title_before', 'date_before_title' );\r\nadd_action( 'astra_archive_post_title_before', 'date_before_title' );\r\n\r\nfunction date_before_title() {\r\n $date = astra_post_date();\r\n echo \"<div class='entry-meta'>$date<\/div>\";\r\n}<\/code><\/pre>\n\n\n\n
Display the categories and tags below the content<\/h2>\n\n\n\n
add_action( 'astra_entry_content_after', 'category_tag_after_post' );\n\r\nfunction category_tag_after_post() {\r\n if ( !is_single() AND !is_archive() AND !is_home() ) {\r\n return false;\r\n }\n\r\n $categories = astra_post_categories();\r\n $tags = astra_post_tags();\r\n echo \"<div class='entry-meta'>$categories \/ $tags<\/div>\";\r\n}<\/code><\/pre>\n\n\n\n