Close

Account

Documentation

Forum

Menu

Custom Fields

  • Post count: 18
    KnowTechie
    March 8, 2017 at 1:51 pm #23248

    HI,

    I get a lot of guest contributors to my site KnowTechie.com and instead of having to create new author profiles for each one, I would like to use a custom field where I just type in their name. This article here (http://www.wpbeginner.com/wp-tutorials/how-to-rewrite-guest-author-name-with-custom-fields-in-wordpress/) says to insert the code found below in to the functions.php folder, but I don’t know where to insert it. Do you have any insight into this?

    add_filter( ‘the_author’, ‘guest_author_name’ );
    add_filter( ‘get_the_author_display_name’, ‘guest_author_name’ );

    function guest_author_name( $name ) {
    global $post;

    $author = get_post_meta( $post->ID, ‘guest-author’, true );

    if ( $author )
    $name = $author;

    return $name;
    }

    Post count: 2485
    Jegbagus
    March 10, 2017 at 4:55 am #23261

    hi KnowTechie, i think there is alot way you can do it.
    you can use hook like above. or you can also head to jmagz-themes > fragment > post-author-box.php
    and modify content of : get_the_author_meta

    Thank you

    Post count: 18
    KnowTechie
    March 10, 2017 at 3:22 pm #23265

    I’m still not exactly sure where I would insert that.

    Here’s my post-author-box.php (fragment/post-author-box.php)code ( can you show me where to insert it?)

    <section class=”author-box”>
    <div class=”author-image”>
    <?php echo get_avatar( get_the_author_meta( ‘ID’ ), 180, null, apply_filters(‘jeg_get_author_name’, null)) ?>
    </div>
    <div class=”author-content”>
    <h2 class=”author-title”><?php _e(‘Author’,’jeg_textdomain’) ?></h2>
    <h3 class=”author-name”>
    “><?php echo apply_filters(‘jeg_get_author_name’, null); ?>
    </h3>
    <div class=”author-socials”>
    <?php if ( get_the_author_meta( ‘facebook’ ) ): ?>
    ” class=”facebook”><i class=”fa fa-facebook-square”></i>
    <?php endif ?>
    <?php if ( get_the_author_meta( ‘twitter’ ) ): ?>
    ” class=”twitter”><i class=”fa fa-twitter”></i>
    <?php endif ?>
    <?php if ( get_the_author_meta( ‘google’ ) ): ?>
    ” class=”google-plus”><i class=”fa fa-google-plus”></i>
    <?php endif ?>
    <?php if ( get_the_author_meta( ‘linkedin’ ) ): ?>
    ” class=”linkedin”><i class=”fa fa-linkedin”></i>
    <?php endif ?>
    </div>
    <p class=”author-description”>
    <?php echo get_the_author_meta(‘description’); ?>
    </p>
    <?php if ( get_the_author_meta(‘user_url’) ): ?>
    <p class=”author-link”><i class=”fa fa-link”></i>
    “><?php the_author_meta(‘user_url’); ?>
    </p>
    <?php endif ?>
    </div>
    </section>

    Post count: 2485
    Jegbagus
    March 15, 2017 at 1:33 am #23283

    hi knowntechie, i will give you example from your example above :

    Post count: 18
    KnowTechie
    March 15, 2017 at 1:06 pm #23287

    I still don’t know where to insert the code. Which line? Can you provide an example with the code already inserted?

    Post count: 6682
    Adek
    March 18, 2017 at 2:12 am #23294

    Hi KnowTechie,

    You can check this one here http://pastebin.com/c6WuVYJb.

    File : jmagz-themes/functions.php

    Thank you

You must be logged in to reply to this topic.