How do I add post info to pages?

Community Forums Forums General Discussion How do I add post info to pages?

This topic is: resolved

Tagged: ,

This topic contains 13 replies, has 6 voices, and was last updated by  jeremyers1 1 year ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #45505

    mathiasppc
    Participant
    Post count: 27

    I 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/
    #45509

    David Chu
    Participant
    Post count: 1364

    Deleted… I misunderstood the question.


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    • This reply was modified 1 year, 3 months ago by  David Chu. Reason: deleted
    • This reply was modified 1 year, 3 months ago by  David Chu. Reason: deleted
    #46594

    mathiasppc
    Participant
    Post count: 27

    Anyone have a solution for this problem?

    #47082

    mathiasppc
    Participant
    Post count: 27

    Bump

    #47237

    Ozzy
    Participant
    Post count: 214

    what is it you’re trying to do with it?


    #47238

    mathiasppc
    Participant
    Post count: 27

    I I just want the post info (author, date and comments) to show up on pages (as it`s already showing up in posts)

    #47268

    tibor
    Participant
    Post count: 20

    Since 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 )  );
    }
    
    • This reply was modified 1 year, 3 months ago by  tibor.
    • This reply was modified 1 year, 3 months ago by  tibor.
    #47295

    mathiasppc
    Participant
    Post count: 27

    Thanks Tibor!

    Do I put this in the page.php in the Genesis Framework though? I thought I was not supposed to edit those files?

    #47297

    tibor
    Participant
    Post count: 20

    You 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

    • This reply was modified 1 year, 3 months ago by  tibor. Reason: typo
    • This reply was modified 1 year, 3 months ago by  tibor. Reason: typo
    #47307

    mathiasppc
    Participant
    Post count: 27

    Thanks 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 doesent work because I think theres something wrong with the if-statement? Without if ( is_page() ) the extra post info shows up on all posts and pages.

    #47319

    braddalton
    Participant
    Post count: 9794

    The 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.


    #47329

    mathiasppc
    Participant
    Post count: 27

    Thanks for the help everyone. Working beautifully!

    #62897

    jeremyers1
    Participant
    Post count: 9

    I 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

    #62901

    jeremyers1
    Participant
    Post count: 9

    Thanks for the code above by braddalton. Didn’t see it before. That worked.


    Blogger and Author

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.