0

my friend asked me to improve his site. He needs to add button to job list post but I don't know how, I am using only HTML/CSS, not PHP.

There is a code:

<?php if( $permalink ) : ?>
            <a href="<?php echo esc_url($permalink);?>"><?php echo $thumbnail_image_output;?></a>
        <?php else:?>
            <?php echo $thumbnail_image_output;?>
        <?php endif;?>          
    </div>
</div>
<?php endif;?>

<div class="person_data">

    <?php if( $permalink ) : ?>
        <h5 class="person_name"><a href="<?php echo esc_url($permalink);?>"><?php the_title();?></a></h5>
    <?php else:?>
        <h5 class="person_name"><?php the_title();?></h5>
    <?php endif;?>

    <?php if(! empty( $position )) : ?>
        <span class="position"><?php echo apply_filters( "rtframework_team_position", esc_attr( $position ) );?></span>
    <?php endif;?>

    <?php if(! empty( $short_data )) : ?>
    <div class="profile">
        <?php echo apply_filters( "the_content", $short_data );?>   
    </div> 
    <?php endif;?>

    <?php do_action("rtframework_staff_media_links",$post->ID); ?>  
</div>  

The question is, how to add button with link to the full post above the "the_content"?

I will be very happy if you show me the way.

Sorry for my English and have nice day :-)

  • Can you explain what you mean by "link to the full post above the 'the_content'"? Do you have a URL you need to use for the button? – Tony Dec 04 '17 at 22:44
  • 1
    You have the `$permalink` used on the thumbnail and title. What prevents you from using the link anywhere else in the page? I suspect the `$permalink` variable is set by using the `get_permalink()` function. – Ionut Tatu Dec 04 '17 at 22:45
  • There is a page -> [link]http://triload.esamtv.cz/?page_id=4002[/link] He just want to add button "Read article" on the staff post. Now you can open it with click on name or image, it's not enough for the visitors (that's what he said to me). – Patrik Štolba Dec 04 '17 at 23:04

2 Answers2

0

I agree with your friend, from a usability viewpoint a "read article" link helps a lot. But it should be below the teaser text, not above. And that's easy to do, just create an tag wherever you want it to be, encapsulate it with a check for $permalink and put <?php echo $permalink; ?> in the href attribute. In this example it would be between the teaser text and the social media buttons (and look like the button on the home page):

<?php if(! empty( $short_data )) : ?>
<div class="profile">
    <?php echo apply_filters( "the_content", $short_data );?>   
</div> 
<?php endif;?>

<?php if( $permalink ) : ?>
    <a href="<?php echo $permalink; ?>" target="_self" title="read more" class="button_  style-1 small"><span><span>read more</span></span></a>
<?php endif;?>

<?php do_action("rtframework_staff_media_links",$post->ID); ?>
masterfloda
  • 2,908
  • 1
  • 16
  • 27
0

You can choose to wrap the a tag around your div

<a href="<?php echo $permalink ?>">
    <div class="person_data">
        <!-- Other HTML tags -->
    </div>
</a>

Having an anchor around a div can be tricky sometimes (especially if you have no experience)

Read about block and inline terms in CSS as well as in HTML.

Here's a good starting point to a SO question.

Ionut Tatu
  • 525
  • 1
  • 7
  • 20