Community Forums › Forums › Archived Forums › General Discussion › How do I add post info to pages?
Tagged: .post-info, page
- This topic has 13 replies, 6 voices, and was last updated 11 years, 6 months ago by
jeremyers1.
-
AuthorPosts
-
June 12, 2013 at 11:37 am #45505
mathiasppc
MemberI tried adding this to functions.php:
//* Customize the post info function
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}I also tried swapping genesis_post_info with genesis_entry_header, but with no luck
Thanks for any comments 🙂
http://energyinformative.org/June 12, 2013 at 12:05 pm #45509David Chu
ParticipantDeleted... I misunderstood the question.
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
June 18, 2013 at 12:29 pm #46594mathiasppc
MemberAnyone have a solution for this problem?
June 21, 2013 at 12:42 pm #47082mathiasppc
MemberBump
June 22, 2013 at 6:46 pm #47237Ozzy
MemberJune 22, 2013 at 6:52 pm #47238mathiasppc
MemberI I just want the post info (author, date and comments) to show up on pages (as it`s already showing up in posts)
June 23, 2013 at 1:33 am #47268tibor
MemberSince the genesis_post_info function does not run on pages, you would have to add it to the page first:
Adding this to your page template (page.php) may do the trick:
add_action( 'genesis_after_post_title', 'my_page_info' ); function my_page_info() { $post_info = '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]'; printf( '<div class="post-info">%s</div>', do_shortcode( $post_info ) ); }
June 23, 2013 at 10:59 am #47295mathiasppc
MemberThanks Tibor!
Do I put this in the page.php in the Genesis Framework though? I thought I was not supposed to edit those files?
June 23, 2013 at 12:22 pm #47297tibor
MemberYou should indeed never edit any Genesis core files. If you want this on all your pages, just add a new file named page.php to your child theme folder and Genesis will use that instead of it's own.
It should look like this:
<?php add_action( 'genesis_after_post_title', 'my_page_info' ); function my_page_info() { $post_info = '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]'; printf( '<div class="post-info">%s</div>', do_shortcode( $post_info ) ); } genesis();
You could also use it in functions.php, but then you'd first have to check if you're on a page post-type.
Actually you might want to see how Genesis uses the post-info function: look in genesis/lib/structure/post.php, at or around line 252
June 23, 2013 at 1:13 pm #47307mathiasppc
MemberThanks again Tibor
Here`s what I put in functions.php
if ( is_page() ) {
add_action( 'genesis_entry_header', 'my_page_info' );
function my_page_info() {
$post_info = '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]';
printf( '<p class="entry-meta">%s</p>', do_shortcode( $post_info ) );
}
}It doesen
t work because I think there
s something wrong with the if-statement? Without if ( is_page() ) the extra post info shows up on all posts and pages.June 23, 2013 at 1:37 pm #47319Brad Dalton
ParticipantThe conditional needs to be added after the function or it won't work.
Code tested and works on Genesis 2.0 HTML 5 Sample child theme.
June 23, 2013 at 2:01 pm #47329mathiasppc
MemberThanks for the help everyone. Working beautifully!
September 16, 2013 at 4:46 pm #62897jeremyers1
MemberI am trying to do this also. I added this to my functions.php file:
function my_page_info() {
$post_info = '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]';
printf( '<p class="entry-meta">%s</p>', do_shortcode( $post_info ) );
}if ( is_page() ) {
add_action( 'genesis_entry_header', 'my_page_info' );
}But nothing is appearing on my pages. Any help?
Blogger and Author
September 16, 2013 at 5:02 pm #62901jeremyers1
MemberThanks for the code above by braddalton. Didn't see it before. That worked.
Blogger and Author
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.