• Resolved jibril84

    (@jibril84)


    Hello!
    Since this plugin already uses Yoast SEO to display social links in the authors list, I was wondering if it was possible to recall the code already written in the plugin to show those links also on the author page, with the same icons.
    Is there anyone kind enough to provide me the PHP code I should put into the author template to do this? Or can you tell me where I can find Yoast documentation about this, since I can’t find it?
    Thank you!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jibril84

    (@jibril84)

    I found it! I’ll put it here in case anyone else needs it. (I only entered the social networks I need, for the others just copy the lines and replace the name of the social network wherever it appears)

    <?php
    $facebook = get_the_author_meta( 'facebook', $post->post_author );
    $twitter = get_the_author_meta( 'twitter', $post->post_author );
    $instagram = get_the_author_meta( 'instagram', $post->post_author );
    $pinterest = get_the_author_meta( 'pinterest', $post->post_author );
    $youtube = get_the_author_meta( 'youtube', $post->post_author );
    
    echo '<a href="'. $facebook .'" rel="nofollow" target="_blank" alt="Facebook"><i class="fab fa-facebook"></i></a> 
    <a href="'. $instagram .'" rel="nofollow" target="_blank" alt="Instagram"><i class="fab fa-instagram"></i></a> 
    <a href="'. $pinterest .'" rel="nofollow" target="_blank" alt="Pinterest"><i class="fab fa-pinterest"></i></a> 
    <a href="https://twitter.com/' . $twitter .'" rel="nofollow" target="_blank" alt="Twitter"><i class="fab fa-twitter"></i></a> 
    <a href="'. $youtube .'" rel="nofollow" target="_blank" alt="YouTube"><i class="fab fa-youtube"></i></a> ';
    ?>
    Thread Starter jibril84

    (@jibril84)

    I forgot to check if the links exist…

    <?php
    $facebook = get_the_author_meta( 'facebook', $post->post_author );
    $twitter = get_the_author_meta( 'twitter', $post->post_author );
    $instagram = get_the_author_meta( 'instagram', $post->post_author );
    $pinterest = get_the_author_meta( 'pinterest', $post->post_author );
    $youtube = get_the_author_meta( 'youtube', $post->post_author );
    			
    if(!empty($facebook)) {
    	echo '<a href="'. $facebook .'" rel="nofollow" target="_blank" alt="Facebook"><i class="fab fa-facebook"></i></a>';
    }
    			
    if(!empty($instagram)) {
    	echo '<a href="'. $instagram .'" rel="nofollow" target="_blank" alt="Instagram"><i class="fab fa-instagram"></i></a>';
    }
    				
    if(!empty($pinterest)) {
    	echo '<a href="'. $pinterest .'" rel="nofollow" target="_blank" alt="Pinterest"><i class="fab fa-pinterest"></i></a>';
    }
    			
    if(!empty($twitter)) {
    	echo '<a href="https://twitter.com/' . $twitter .'" rel="nofollow" target="_blank" alt="Twitter"><i class="fab fa-twitter"></i></a>';
    }
    				
    if(!empty($youtube)) {
    	echo '<a href="'. $youtube .'" rel="nofollow" target="_blank" alt="YouTube"><i class="fab fa-youtube"></i></a>';
    }
    
    ?>
    Plugin Author WPKube

    (@wpkube)

    Hi @jibril84

    Happy to hear you figured out a solution. To use the one from the plugin you would go with:

    echo authors_list_display_social(array(
        'user_id' => get_query_var( 'author' ),
    ));

    Keep in mind that it will be unstyled because the CSS form the plugin won’t be added on that page, so add this CSS:

    .authors-list-item-social {
        margin-bottom: 10px;
    }
    
        .authors-list-item-social a {
            font-size: 15px;
            margin-right: 5px;
            text-decoration: none;
        }
        
            .authors-list-item-social svg {
                width: 15px;
            }
    
            .authors-list-item-social-facebook {
                fill: #3b5998;
            }
    
            .authors-list-item-social-instagram {
                fill: #405de6;
            }
    
            .authors-list-item-social-linkedin {
                fill: #0077b5;
            }
    
            .authors-list-item-social-pinterest {
                fill: #bd081c;
            }
    
            .authors-list-item-social-tumblr {
                fill: #35465c;
            }
    
            .authors-list-item-social-twitter {
                fill: #1da1f2;
            }
    
            .authors-list-item-social-youtube {
                fill: #ff0000;
            }
    Thread Starter jibril84

    (@jibril84)

    Thank you so much!

    Plugin Author WPKube

    (@wpkube)

    You’re welcome.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP code to display social links in author’s page’ is closed to new replies.