• I’m trying to get it so that when a certain author makes a post, a link will be given to their website. I want this link to be an image link, though, and not a text link. The image is unique to them and is put in the post with this code:

    <?php if ( get_post_meta($post->ID, 'profile', true) ) { ?>
    
    <div class="profile_img_home"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/profile/<?php echo get_post_meta($post->ID, "profile", $single = true); ?>" alt="<?php the_author(); ?>" /></div>
    
    <?php } ?>

    Basically, they go down into the custom fields section and enter in the last portion of the image location (i.e. michael.gif) and the iamge will be put in the post if they’ve entered that bit.

    What I’m wondering, is how do I work this code with the_author_link? Do I put the code above in the brackets of the code following:

    <?php the_author_link(); ?>

    Any help is greatly appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter mithrustt

    (@mithrustt)

    I’ve been working with in, but I still can’t quite get it. This is what I have:

    <?php if ( get_post_meta($post->ID, 'profile', true) ) { ?>
    
    <div class="profile_img_home"><a href="<?php the_author_link(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/profile/<?php echo get_post_meta($post->ID, "profile", $single = true); ?>" alt="<?php the_author(); ?>" /></a></div>
    
    <?php } ?>

    Any ideas?

    Try this. Paste it into either single.php if it’s a post, or page.php if it’s a page.

    <a href="<?php $values = get_post_custom_values("url"); echo $values[0]; ?>" title="<?php the_title(); ?>">
    				<img src="<?php $values = get_post_custom_values("image"); echo $values[0]; ?>" alt="" /></a>

    The first one, called “url” will turn the image into a link. So they’d create a custom field called “url” and then type in the website address. Then make a second field called “image” (you can rename either of those if you want) and paste in the image location. It’ll automatically put in those custom fields when they publish their post.

    Thread Starter mithrustt

    (@mithrustt)

    That’s what I’m trying to avoid. I don’t want to be putting a lot of extra work on the shoulders of the writers every time they make a post.

    I have the image up and working now. I just want to give it the_author_link. I’m just not sure how to work the link in with the image code that I posted above.

    Thread Starter mithrustt

    (@mithrustt)

    OK, I’ve been continually working on this and it’s really starting to bother me. It seems like something so simple, and yet, I can’t get it to work. This is the code I have:

    <?php if ( get_post_meta($post->ID, 'profile', true) ) { ?>
    
    <div class="profile_img_home"><a href="<?php the_author_link(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/profile/<?php echo get_post_meta($post->ID, "profile", $single = true); ?>" alt="<?php the_title(); ?>" /></a></div>
    
    <?php } ?>

    You can see that I have the_author_link in there. I have this same code elsewhere on the site, but instead of the_author_link, I have the_permalink, and it works fine. So, I’m really not sure why it doesn’t work when I make this simple switch.

    To see the problem I’m having, go here and look for the image to the right of the post title. You can see the link text “Michael Fox” which should be a link around the image instead.

    https://think-theory.com/metroid-prime-3-corruption/

    Any ideas?

    Thread Starter mithrustt

    (@mithrustt)

    I really hate to bump, but this is starting to really bother me. I don’t get what I’m doing wrong. Surely someone here can point out my stupidity by showing what simple thing I’ve missed. Also, if it helps, the link when hovered, shows up as:

    https://think-theory.com/whatever-the-article-title-is/<a href=

    I have no idea why it’s doing this either.

    all you need to do is click on the author’s name and all sorts of fun stuff comes up!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Author’s website’ is closed to new replies.