Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Add First & Last Page to Paginate_Links WordPress

  • SOLVED

I have the following code in my template file.

It shows paginated links like in the attached image.

I am trying to add a button at the beginning and end of the links to jump to first page and jump to last page. I want to buttons to simply be "<" for First page and ">" for Last Page. Can anyone help me figure this out? Been researching online and not finding a solution based on my custom term query below.

<?php
/*
Template Name: 100 List Page
*/
?>
<?php get_header(); ?>
<div class="row heading-grid">
<div class="container">
<div id="heading-position">
<div class="col-lg-12">
<h2><span class="heading-grid-title"><span class="glyphicon glyphicon-th icon-white"></span> <?php the_title(); ?></span></h2>
<div id="breadcrumbs"> <small><?php if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
} ?></small></div>
</div>
</div>
</div><!-- close container -->
</div><!-- close row services -->
<div id="spacer"></div>

<div class="container">
<div class="row">
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<article> <!-- Grid Key -->
<div class="row">
<div class="col-lg-12">
<?php include("grid-key.php"); ?>
</div>
<div class="col-sm-12 col-xs-12 hidden-lg hidden-md">
<?php include("sidebar100list-mobile.php"); ?>
</div> <!-- End col-12 -->
</div>
<?php if(!empty($_REQUEST['noresults'])) echo '<div class="alert alert-warning">The equity "'. htmlentities ($_REQUEST['noresults']) .'" you just searched was not shortlisted for inclusion in our Alpha Grid database because other equity instruments in this sector and/or alternative industries have been assessed with better sentiment-driven alpha opportunities at this time. Your symbol of interest will be added when it meets our stringent screening criteria for getting rated with at least a one star status.</div>'; ?>
<!-- Grid Key -->
<!-- Content Protection -->
<?php ob_start();?>
<!-- Content Protection -->
<div class="row" >
<?php
global $alpha_total_number_of_pages;

$args = array (
'output_taxonomy' => '100gridgroups',
'order_by_taxonomy' => 'grid-star-rating',
'current_page' => (get_query_var( 'paged' ))? get_query_var( 'paged' ) : 1
);
$libcats = mon_get_alpha_terms( $args );
# Note: if starts here checking if $libcats not false
if($libcats) {

$i = 0;
foreach($libcats as $lc){
if( $i % 4 == 0 )


{ ?>
<div class="clearfix"></div>
<?php }
$i++; ?>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6" >
<?php $termlink = get_term_link( $lc->slug, '100gridgroups' ); ?>
<div class="panel panel-default">
<div class="panel-image">
<?php if( get_field('is_"new"_mega_trend', '100gridgroups_'.$lc->term_id) != 'newmegatrendyes' ) { ?>

<?php } else { ?>
<div class="new-icon"><img src="http://www.runningalpha.com/wp-content/themes/runningalpha/img/new.png" /></div>
<?php } ?>
<div class="thumbnail">
<div class="caption hidden-md hidden-sm hidden-xs">
<br/>
<h5><?php echo $lc->name; ?> </h5>


<!-- Popover Start -->
<div class="po-markup" ><a href="<?php echo $termlink;?>" class="p5598 popover-dismiss btn btn-info btn-lg"><?php echo $lc->count ?> Symbols</a>
<br/><h4><a class="label" href="<?php echo $termlink;?>">Open Group</a></h4>

<div class="po-content hidden popover">
<div class="po-title">
<div class="row"><div class="col-lg-8">
<h4><?php echo $lc->name; ?> Symbols </h4></div><div class="col-lg-4"><h4><span class="pull-right"><span class="label label-info"><?php echo $lc->count ?> Active</span>
<?php if(mgm_user_is(array('trendpiece','focus15'))) {
include("term-momentum-flag-mobile.php");
} else {
echo '<small><span class="glyphicon glyphicon-eye-close text-muted"></span></small>';
}?></h4></span>
</div></div>

</div> <!-- ./po-title -->
<div class="po-body">

<?php if(mgm_user_is(array('trendpiece','focus15'))) {
include("symbol-list-popover.php");
} else {
echo '<div class="widget-area"><div class="alert alert-info"><span class="glyphicon glyphicon-eye-close"></span> You need to be a subscriber to see the full content.<br/><br/> <a class="btn btn-md btn-info" href="http://www.runningalpha.com/subscriptions/"> Access Now</a></div></div>';
}?>

<br/>
<a class="btn btn-navy btn-block" href="<?php echo $termlink; ?>">View All <?php echo $lc->count ?> Symbols</a>

</div><!-- ./po-body -->
</div> <!-- ./po-content -->
</div><!-- ./po-markup -->

<!-- Popover End --> <br/>


</div>

<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field('taximage', '100gridgroups_'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
else { ?>
<a class="mobile-group-link" href="<?php echo $termlink; ?>"><img class="img-responsive" src="http://www.runningalpha.com/wp-content/uploads/2014/09/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" /></a>
<?php } ?>
<!-- description div -->
<div id="deschide">
<div class="<?php if(get_field('level_of_interest', '100gridgroups_'.$lc->term_id)) {
echo the_field('level_of_interest', '100gridgroups_'.$lc->term_id);

} else { ?>intleveldefault<?php } ?>">
<!-- description content -->
<div class="description_content"> <a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a> </div>
<!-- end description content -->
</div> </div>

<!-- end description div -->

</div>

<!-- Get Image by Attachment ID End-->



</div>

<div class="panel-footer text-center">
<!-- Icons -->
<div class="row">
<!-- LG Screen -->
<div class="col-lg-4 visible-lg">
<div class="<?php if(get_field('heat_level', '100gridgroups_'.$lc->term_id)) {
echo the_field('heat_level', '100gridgroups_'.$lc->term_id); } else { ?>heatleveldefault<?php } ?>"></div>
</div>

<div class="col-lg-8 visible-lg">
<div class="<?php echo mon_get_rating_class($lc->rating); ?>"></div></div>
<!-- LG Screen -->
<!-- MD, SM, XS Screen -->
<div class="hidden-lg col-md-12 col-sm-12 col-xs-12">
<center> <div class="<?php if(get_field('heat_level', '100gridgroups_'.$lc->term_id)) {
echo the_field('heat_level', '100gridgroups_'.$lc->term_id); } else { ?>heatleveldefault<?php } ?>"></div></center>
</div>

<div class="hidden-lg col-md-12 col-sm-12 col-xs-12">
<center> <div class="<?php echo mon_get_rating_class($lc->rating); ?>"></div></center></div>
<!-- MD, SM, XS Screen -->


</div><!-- end row -->
<!-- Icons -->
</div>
</div>
</div>



<?php } ?>
</div>
<!-- Pagination Start -->
<div class="text-center">
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links(
array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '/page/%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $alpha_total_number_of_pages,
'type' => 'list',
'end_size' => 5,
'mid_size' => $mid_size,
'prev_text' => __('<'),
'next_text' => __('>'),
)
);
?></div>
<!-- Pagination End -->
<?php
//Note: and ends here
} else {
echo '<div class="col-lg-12"><div class="alert alert-info">Sorry, this page does not have any active industries at this time. Please check back soon.</div></div>';
}
?>
<!-- Content Protection -->
<?php echo do_shortcode('[private]'.ob_get_clean().'[/private]' ); ?>
<!-- Content Protection -->
</article>

</div> <!-- End col-md-9 -->
<div class="col-lg-3 col-md-3 hidden-sm hidden-xs">
<?php include("sidebar100list.php"); ?>
</div> <!-- End col-md-3 -->
</div><!-- End row -->
</div><!-- End Container -->
<?php get_footer(); ?>


Answers (3)

2014-12-16

Romel Apuya answers:

try this


<?php

/*

Template Name: 100 List Page

*/

?>

<?php get_header(); ?>

<div class="row heading-grid">

<div class="container">

<div id="heading-position">

<div class="col-lg-12">

<h2><span class="heading-grid-title"><span class="glyphicon glyphicon-th icon-white"></span> <?php the_title(); ?></span></h2>

<div id="breadcrumbs"> <small><?php if ( function_exists('yoast_breadcrumb') ) {

yoast_breadcrumb('<p id="breadcrumbs">','</p>');

} ?></small></div>

</div>

</div>

</div><!-- close container -->

</div><!-- close row services -->

<div id="spacer"></div>



<div class="container">

<div class="row">

<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">

<article> <!-- Grid Key -->

<div class="row">

<div class="col-lg-12">

<?php include("grid-key.php"); ?>

</div>

<div class="col-sm-12 col-xs-12 hidden-lg hidden-md">

<?php include("sidebar100list-mobile.php"); ?>

</div> <!-- End col-12 -->

</div>

<?php if(!empty($_REQUEST['noresults'])) echo '<div class="alert alert-warning">The equity "'. htmlentities ($_REQUEST['noresults']) .'" you just searched was not shortlisted for inclusion in our Alpha Grid database because other equity instruments in this sector and/or alternative industries have been assessed with better sentiment-driven alpha opportunities at this time. Your symbol of interest will be added when it meets our stringent screening criteria for getting rated with at least a one star status.</div>'; ?>

<!-- Grid Key -->

<!-- Content Protection -->

<?php ob_start();?>

<!-- Content Protection -->

<div class="row" >

<?php

global $alpha_total_number_of_pages;



$args = array (

'output_taxonomy' => '100gridgroups',

'order_by_taxonomy' => 'grid-star-rating',

'current_page' => (get_query_var( 'paged' ))? get_query_var( 'paged' ) : 1

);

$libcats = mon_get_alpha_terms( $args );

# Note: if starts here checking if $libcats not false

if($libcats) {



$i = 0;

foreach($libcats as $lc){

if( $i % 4 == 0 )





{ ?>

<div class="clearfix"></div>

<?php }

$i++; ?>

<div class="col-lg-3 col-md-3 col-sm-3 col-xs-6" >

<?php $termlink = get_term_link( $lc->slug, '100gridgroups' ); ?>

<div class="panel panel-default">

<div class="panel-image">

<?php if( get_field('is_"new"_mega_trend', '100gridgroups_'.$lc->term_id) != 'newmegatrendyes' ) { ?>



<?php } else { ?>

<div class="new-icon"><img src="http://www.runningalpha.com/wp-content/themes/runningalpha/img/new.png" /></div>

<?php } ?>

<div class="thumbnail">

<div class="caption hidden-md hidden-sm hidden-xs">

<br/>

<h5><?php echo $lc->name; ?> </h5>





<!-- Popover Start -->

<div class="po-markup" ><a href="<?php echo $termlink;?>" class="p5598 popover-dismiss btn btn-info btn-lg"><?php echo $lc->count ?> Symbols</a>

<br/><h4><a class="label" href="<?php echo $termlink;?>">Open Group</a></h4>



<div class="po-content hidden popover">

<div class="po-title">

<div class="row"><div class="col-lg-8">

<h4><?php echo $lc->name; ?> Symbols </h4></div><div class="col-lg-4"><h4><span class="pull-right"><span class="label label-info"><?php echo $lc->count ?> Active</span>

<?php if(mgm_user_is(array('trendpiece','focus15'))) {

include("term-momentum-flag-mobile.php");

} else {

echo '<small><span class="glyphicon glyphicon-eye-close text-muted"></span></small>';

}?></h4></span>

</div></div>



</div> <!-- ./po-title -->

<div class="po-body">



<?php if(mgm_user_is(array('trendpiece','focus15'))) {

include("symbol-list-popover.php");

} else {

echo '<div class="widget-area"><div class="alert alert-info"><span class="glyphicon glyphicon-eye-close"></span> You need to be a subscriber to see the full content.<br/><br/> <a class="btn btn-md btn-info" href="http://www.runningalpha.com/subscriptions/"> Access Now</a></div></div>';

}?>



<br/>

<a class="btn btn-navy btn-block" href="<?php echo $termlink; ?>">View All <?php echo $lc->count ?> Symbols</a>



</div><!-- ./po-body -->

</div> <!-- ./po-content -->

</div><!-- ./po-markup -->



<!-- Popover End --> <br/>





</div>



<!-- Get Image by Attachment ID Start-->

<?php

$attachment_id = get_field('taximage', '100gridgroups_'.$lc->term_id);

if ($attachment_id) {

$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');

if ($image) {

?>

<img class="img-responsive" src="<?php echo $image[0]; ?>" />

<?php

}

}

else { ?>

<a class="mobile-group-link" href="<?php echo $termlink; ?>"><img class="img-responsive" src="http://www.runningalpha.com/wp-content/uploads/2014/09/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" /></a>

<?php } ?>

<!-- description div -->

<div id="deschide">

<div class="<?php if(get_field('level_of_interest', '100gridgroups_'.$lc->term_id)) {

echo the_field('level_of_interest', '100gridgroups_'.$lc->term_id);



} else { ?>intleveldefault<?php } ?>">

<!-- description content -->

<div class="description_content"> <a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a> </div>

<!-- end description content -->

</div> </div>



<!-- end description div -->



</div>



<!-- Get Image by Attachment ID End-->







</div>



<div class="panel-footer text-center">

<!-- Icons -->

<div class="row">

<!-- LG Screen -->

<div class="col-lg-4 visible-lg">

<div class="<?php if(get_field('heat_level', '100gridgroups_'.$lc->term_id)) {

echo the_field('heat_level', '100gridgroups_'.$lc->term_id); } else { ?>heatleveldefault<?php } ?>"></div>

</div>



<div class="col-lg-8 visible-lg">

<div class="<?php echo mon_get_rating_class($lc->rating); ?>"></div></div>

<!-- LG Screen -->

<!-- MD, SM, XS Screen -->

<div class="hidden-lg col-md-12 col-sm-12 col-xs-12">

<center> <div class="<?php if(get_field('heat_level', '100gridgroups_'.$lc->term_id)) {

echo the_field('heat_level', '100gridgroups_'.$lc->term_id); } else { ?>heatleveldefault<?php } ?>"></div></center>

</div>



<div class="hidden-lg col-md-12 col-sm-12 col-xs-12">

<center> <div class="<?php echo mon_get_rating_class($lc->rating); ?>"></div></center></div>

<!-- MD, SM, XS Screen -->





</div><!-- end row -->

<!-- Icons -->

</div>

</div>

</div>







<?php } ?>

</div>

<!-- Pagination Start -->

<div class="text-center">

<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
$max = intval( $wp_query->max_num_pages );
echo paginate_links(
array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '/page/%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $alpha_total_number_of_pages,
'type' => 'list',
'end_size' => 5,
'mid_size' => $mid_size,
'prev_text' => __('<'),
'next_text' => __('>'),
'before_page_number' => '<a href="'.esc_url( get_pagenum_link( 1 ) ).'"><</a>',
'after_page_number' => '<a href="'.esc_url( get_pagenum_link( $max ) ).'">></a>',
)
);

?></div>

<!-- Pagination End -->

<?php

//Note: and ends here

} else {

echo '<div class="col-lg-12"><div class="alert alert-info">Sorry, this page does not have any active industries at this time. Please check back soon.</div></div>';

}

?>

<!-- Content Protection -->

<?php echo do_shortcode('[private]'.ob_get_clean().'[/private]' ); ?>

<!-- Content Protection -->

</article>



</div> <!-- End col-md-9 -->

<div class="col-lg-3 col-md-3 hidden-sm hidden-xs">

<?php include("sidebar100list.php"); ?>

</div> <!-- End col-md-3 -->

</div><!-- End row -->

</div><!-- End Container -->

<?php get_footer(); ?>


streetfire comments:

Hi Romel,

That gives a bit of a messed up nav. See attached.