navigational links for single custom post type

this time i need to add pagination or navigational links for single custom post type and after looking around in google i didn’t find the best answer so am giving it to you

first in the single custom post type template like single-property.php in my case

u need to add this under main content


<?php 
global $post;
if (is_single() ){ 
    ob_start();
    previous_post_link('%link', '%title',false);
    $template_pr = ob_get_contents();
    ob_end_clean(); 
    
    ob_start();
    next_post_link('%link',' %title',false); 
    $template_nxt = ob_get_contents();
    ob_end_clean(); 
    
?>
<div class="navigational_links">
    <?php if( $template_pr !=''){?>
            <div class="nav-prev-wrapper">
                <div class="nav-prev">
                    <?php print $template_pr; // previous_post_link('%link', '%title',false);?>
                    <i class="fa fa-angle-left"></i>           
                </div>
            </div>
    <?php } ?>
     
    <?php if( $template_nxt !=''){?>
            <div class="nav-next-wrapper">
                 <div class="nav-next">    
                     <i class="fa fa-angle-right"></i>
                     <?php print $template_nxt;// next_post_link('%link',' %title',false);  ?>
                 </div>
            </div>  
    <?php }?>
</div> 
  
<?php
}
?>
	
 

add this amazing css code


.nav-prev-wrapper{
    position: fixed;
    height: 110px;
    top: 50%;
    width: 250px;
    background: #2b2937;
    color: #fff;
    margin-top: -55px;
    text-decoration: none;
    z-index: 200;
    left:-245px;
    border-top-right-radius:4px;
    border-bottom-right-radius:4px;
    cursor:pointer;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
     padding: 0px 15px;
    display: table;
}

.nav-prev-wrapper:hover{
    left:0px;
}

.nav-next-wrapper i,
.nav-prev-wrapper i{
    display: inline;
    float: left;
    font-size: 20px;
    line-height: 22px;
    top: 50%;
    margin-top: -11px;
}

.nav-next-wrapper i{
    margin-left: 5px;
    margin-right: 5px;
    position: absolute;
    left:12px;
}

.nav-prev-wrapper i{
    position: absolute;
    right: 16px;
}

.nav-next-wrapper{
    position: fixed;
    height: 110px;
    top: 50%;
    width: 250px;
    background: #2b2937;
    color: #fff;
    margin-top: -55px;
  
    text-decoration: none;
    z-index: 200;
    right: -235px;
    margin-left: -40px;

    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    cursor: pointer;
     -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    padding: 0px 15px;
    display: table;
    
}

.nav-next-wrapper:hover{
     right: 0px;
}
.navigational_links a,
.navigational_links a:hover{
    color:#fff;
    text-decoration: none;
}

.nav-prev,
.nav-next{
    display: table-cell;
    vertical-align: middle;
}

.nav-prev{
    text-align: right;
}

.nav-prev a{
display: block;
padding-right: 25px;
line-height: 20px;
max-width: 250px;

float: right;
text-align: right;
}

.nav-next a{
    margin-left: 24px;
    line-height: 20px;
    padding-left: 1PX;
    display: inline;
    float: left;
    max-width:250px;
   
}


@media only screen and (max-width: 992px){
	.navigational_links{
        display:none;   
    }
	
}
 

thanks to annapx for helping me ๐Ÿ™‚

Advertisements

Leave a Reply :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s