How to insert WP previous_post_link(); anchored in a div

Asked

Viewed 50 times

0

Good evening, I’m wanting to create a custom navigation between single-posts in Wordpress, but I don’t know how to do, and I don’t want to use a plugin for this, see what I’m trying to do (No Success Whatsoever!):

*.php

<a href="<?php next_post_link();?>">
        <div  class="seta-next">
            <i></i>
        </div>
    </a>
    <a href="<?php previous_post_link(); ?>">
        <div class="seta-prev">
            <i></i>
        </div>
    </a>  

*.css

.seta-prev{ 
    padding:15px 20px; 
    border:6px solid #ccc; 
    border-radius:50px; 
    float:left; 
    margin:0 10px; 
    box-shadow: 0 0 4px rgba(0,0,0,0.7); 
    transition:all linear 0.2s; 
}
.seta-prev i{ 
    border-right: 20px solid #ccc; 
    border-top: 15px solid transparent;  
    border-bottom: 15px solid transparent; 
    float:left; 
}

.seta-prev:hover{
    transform: rotateX(180deg)
}

.seta-next{ 
    position: relative;
    padding:15px 20px; 
    border:6px solid #ccc; 
    border-radius:50px; 
    top: 50%;
    float:right; 
    margin:0 10px; 
    box-shadow: 0 0 4px rgba(0,0,0,0.7); 
    transition:all linear 0.2s; 
}
.seta-next i{ 
    border-left: 20px solid #ccc; 
    border-top: 15px solid transparent;  
    border-bottom: 15px solid transparent; float:left; 
}

.seta-next:hover{
    transform: rotateX(180deg)
}

1 answer

0


I solved my problem, people:

<?php $prev_post = get_previous_post(); ?>
<?php $next_post = get_next_post(); ?>
<a href="<?php echo esc_url( get_permalink( $prev_post->ID ) ); ?>">
      <div  class="seta-next">
        <i></i>
      </div>
</a>
<a href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
      <div class="seta-prev">
        <i></i>
      </div>
</a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.