Elementor

In this video, you will see how to create and display a custom author box based upon the nickname value for the author as noted in the author’s user profile in the WordPress admin Users area.

GeneratePress is the theme and the GeneratePress Premium add on is used to facilitate the GP Hooks functionality. GP Hooks also has the ability to optionally execute PHP, which is needed for this process.

Resources:

Note: substitute “author-1-nickname”, etc., and “XXX” with your own values.

<?php  $author = get_the_author_meta('nickname'); if (is_single())

switch ($author) {
    case "author-1-nickname":
        echo do_shortcode('[INSERT_ELEMENTOR id="XXX"]');
        break;
    case "author-2-nickname":
        echo do_shortcode('[INSERT_ELEMENTOR id="XXX"]');
        break;
    case "author-3-nickname":
        echo do_shortcode('[INSERT_ELEMENTOR id="XXX"]');
}
?>

If you have only the one author, then you can use this code instead, substituting the “XXX” with your own value.

<?php if ( is_single() ) { ?>
    <?php echo do_shortcode('[INSERT_ELEMENTOR id="XXX"]'); ?>
<?php } ?>

 

Similar Posts

2 Comments

  1. Hi Lyle

    I am using the most current Elementor and GeneratePress Premium which now uses “elements” one of which is “hooks.” I added the Code as displayed using the first names for each user who is an Author in WP. (I didn’t see where a nickname is used.) I set the Hook parameters as: after_content, Execute PHP, Priority 10. For display rules, I selected POST-All posts with no
    exclusions and the user role is Author. Unfortunate nothing works as expected. Here is the CODE

    Any ideas?

    1. The nickname is a required field for each User. It’s in the User Profile 🙂
      Try it with that.
      Cheers!
      Lyle

Leave a Reply

Your email address will not be published. Required fields are marked *