Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Display author etc. in front page

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #191948
    AnniS
    Participant

    Hello all,

    It would be great if someone could help me with my school project. I just can’t figure out what to do over here:

    I’d like to show posts author etc. information already in the first page, as it’s shown on a post page (http://opiskelijablogi.annisalo.net/2014/12/moikka-maailma/). At the moment posts in the first page look like this: http://opiskelijablogi.annisalo.net. I want to have that row “Julkaissut Anni Salo 19.12.2014 kategoriassa Yleinen • 2 kommenttia” to show already in the first page just right below the header of a post.

    Kindly let me know if you need any other information.

    Many, many thanks for your help already in advance.
    And happy new year! :)

    #192055
    AnniS
    Participant

    I have tried to add this from content-header.php:

    <?php
    $display_author = $bavotasan_theme_options[‘display_author’];
    if ( $display_author )
    printf( __( ‘Julkaissut %s’, ‘arcade’ ),
    ‘ . get_the_author() . ‘
    );

    $display_date = $bavotasan_theme_options[‘display_date’];
    if( $display_date ) {
    if( $display_author )
    echo ‘ ‘ . __( ”, ‘arcade’ ) . ‘ ‘;

    echo ‘<time class=”date published updated” datetime=”‘ . get_the_date( ‘Y-m-d’ ) . ‘”>’ . get_the_date() . ‘</time>‘;
    }

    $display_categories = $bavotasan_theme_options[‘display_categories’];
    if( $display_categories ) {
    if( $display_author || $display_date )
    echo ‘ ‘ . __( ‘kategoriassa’, ‘arcade’ ) . ‘ ‘;

    the_category( ‘, ‘ );
    }

    $display_comments = $bavotasan_theme_options[‘display_comment_count’];
    if( $display_comments && comments_open() ) {
    if ( $display_author || $display_date )
    echo ‘ • ‘;

    comments_popup_link( __( ‘0 kommenttia’, ‘arcade’ ), __( ‘1 kommentti’, ‘arcade’ ), __( ‘% kommenttia’, ‘arcade’ ) );
    }
    ?>

    to content.php but all I get is a blank row in front page under the posts header (it’s now there). When I add text to content.php below the posts header, it shows also the text in post page (there’s now example). Nonetheless, it doesn’t show that blank row (nor publication information as a double) in the post page.

    Is it possible that somewhere is command to not to show that particular info row in front page?

    #192297
    Alen
    Participant

    @annis

    Display author etc. in front page

    Front page as in Home Page? Page Template? Read over WordPress Template Hierarchy and make sure you’re editing the right template.

    List of Template Tags that you can use. And here’s a sample code.

    <?php
        $post_author = get_the_author();
        $post_date = get_the_date();
        echo '<p>Published on: '.$post_date.' by '.$post_author.'</p>';
    ?>
    

    or (both produce same results)

    <p>Published on: <?php the_date(); ?> by <?php the_author(); ?></p>
    

    Hope that helps,
    -Alen

    #192629
    AnniS
    Participant

    @chrisburton

    I’m not sure about that, I’ll try to check it. :D


    @AlenAbdula

    If I put one of those example codes, it’s ok in the first page, but then I have publication information twice in the post page.

    #192634
    AnniS
    Participant

    YAYYY, I solved it! I just had to move following code

    &lt;?php if ( ! is_front_page() || 1 &lt; $paged ) { ?&gt;

    after the publication information code – previously it was before it.

    It was too simple :)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.