Elementor

Conditional Author Box

Get the latest from
Sniffle Valve

Sniffle Valve

Consider buying Sniffle Valve a coffee  

Book a one-on-one online training session

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"]');
}
?>
Code for multiple authors

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 } ?>
Code for one author only

Leave a Comment

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

Scroll to Top