php - How to display the date underneath posts on home page? -


new coding. in advance :)

i've gotten date display on posts after they've been clicked (one post on single page) won't show on main page posts.

how apply posts on main/front/home page? how modify in css? (change color or font, instance)

this in functions.php:

function add_after_post_content($content) {     if(!is_feed() && !is_front_page() && !is_home() && is_singular() && is_main_query()) {         $content .= '<p> posted '.date('f j, y').'&nbsp;'.'</p>';     }     return $content; } add_filter('the_content', 'add_after_post_content'); 

for php in functions.php, try changing this:

function add_after_post_content($content) {     if(!is_feed() && is_singular() && is_main_query()) {         $content .= '<p> posted '.date('f j, y').'&nbsp;'.'</p>';     }     return $content; } add_filter('the_content', 'add_after_post_content'); 

basically, second line of function uses !is_front_page() && !is_home() "if not home page , not front page execute code", !is_home being way php/wordpress checks if not true.

for styling, can add class <p> tag in code, this:

$content .= '<p class="my-date-style"> posted '.date('f j, y').'&nbsp;'.'</p>';

then add css file:

.my-date-style {   color: blue; } 

without seeing rest of code it's difficult sure, should headed in right direction.


Comments