Different Featured Images for Non-Users on WordPress?

Is there a way to show an alternate Featured Image to the users that are not logged into my WordPress blog?

So that I can upload 2 Featured Images per post. 1 for users that are logged in, and 1 to display non-logged in visitors.

Read More

Let me know your thoughts. Thanks

Related posts

Leave a Reply

1 comment

  1. AFAIK you cannot have more than one featured image per post. You can get an equivalent functionality using one of my favorite plugins, attachments, which lets you attach media library items to a post, to be accessed in your template files with php.

    Attachments: http://wordpress.org/plugins/attachments/

    So for each post, you could give it a featured image, then also give it an attached image. Once you install attachments, you will have the option to attach items to a post on the standard post editing screen. Once you do that, some code like this should do what you want:

    <?php
    
    if (is_user_logged_in()) {
        //show featured image to logged in user
        the_post_thumbnail('thumbnail');
    } else {
        //show alternate image to non logged in user, using the attachments plug in
        $attachments = new Attachments('attachments');
        //you know they will exist, but we do this check to be safe so we don't try to call methods from a null object
        if ($attachments->exist()) 
        {
            $attachments->get();
        //we could also loop like
        //while ($attachments->get()) {...}
        //if there were more than one, but for this purpose its just one, so then
            echo $attachments->image('thumbnail');
        }
    }
    ?>