Asked  2 Years ago    Answers:  5   Viewed   263 times

I want to add a numberic pagination to a page with its child pages. This is the pagination I would want to create (from bootstrap):

  <ul class="pagination">
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
    <li><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">5</a></li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>

And this is my code:

<!-- block -->
<div class="row grid events-block">

    $parent = $post->ID;
    // query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
    query_posts(array('posts_per_page'=>'1', 'post_type' => 'page', 'post_parent' => $parent, 'paged' => get_query_var('paged')));
        while (have_posts()) : the_post();

    <!-- item -->
    <div class="grid-item col-md-6 col-sm-6 col-xs-12 event-item">

        <div class="date-box">
            <?php echo $event_dates; ?>

        <div class="event-item-text-box">
            <div class="event-item-text-inner-box">
                <h3 class="heading-item"><a href="#" target="_blank"><?php the_title(); ?></a></h3>
                <p><?php the_excerpt(); ?></p>

    <!-- item -->
     <?php endwhile; ?>

     // Reset the post to the original after loop. otherwise the current page becomes the last item from the while loop.

<!-- block -->

<?php $args = array(
    'base'               => '%_%',
    'format'             => '?paged=%#%',
    'total'              => 1,
    'current'            => 0,
    'show_all'           => false,
    'end_size'           => 1,
    'mid_size'           => 2,
    'prev_next'          => true,
    'prev_text'          => __('« Previous'),
    'next_text'          => __('Next »'),
    'type'               => 'plain',
    'add_args'           => false,
    'add_fragment'       => '',
    'before_page_number' => '',
    'after_page_number'  => ''
); ?>

<?php echo paginate_links( $args ); ?>

But I can't get it working. Any ideas what I have missed?



Pagination Like : Prev 1 2 3 Next

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$data= new WP_Query(array(
    'post_type'=>'YOUR_POST_TYPE', // your post type name
    'posts_per_page' => 3, // post per page
    'paged' => $paged,

if($data->have_posts()) :
    while($data->have_posts())  : $data->the_post();
            // Your code

    $total_pages = $data->max_num_pages;

    if ($total_pages > 1){

        $current_page = max(1, get_query_var('paged'));

        echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => '/page/%#%',
            'current' => $current_page,
            'total' => $total_pages,
            'prev_text'    => __('« prev'),
            'next_text'    => __('next »'),
<?php else :?>
<h3><?php _e('404 Error&#58; Not Found', ''); ?></h3>
<?php endif; ?>
<?php wp_reset_postdata();?>

Could you please try above code? I think it's helpful for you.

Saturday, December 17, 2022

The regex you have isn't going to match properly, it's missing several things. I've changed and simplified it a bit, so if the structure of the unordered list isn't the same every time you may need to modify this. Here is the regex updated in the function:

function addlink_replace($string) {
    $pattern = '/<ul(.*?)class="slides"(.*?)<img(.*?)src="(.*?)"(.*?)>(.*?)</ul>/is';
    $replacement = '<ul$1class="slides"$2<a href="$4"><img$3src="$4"$5></a>$6</ul>';
    return preg_replace($pattern, $replacement, $string);

Basically this will match any unordered list that has the class slides, followed by anything up to an image tag, it will capture anything before the source attribute, it will capture the image source itself, anything in the image tag after the source attribute, then anything up to the closing tag of the unordered list.

The replacement will be the same string, but with the anchor tag around the image with the href attribute the same as the image src.

I made a sample output of this on regex101, there is a detailed explanation in the right side column of what it's matching.

Tuesday, November 29, 2022

The easiest would be to use one container and put all the contetn items in it, then equal their height via js like that.


<?php query_posts('posts_per_page=9');while (have_posts()) : the_post();?>
    <div class="col-sm-4 blog-post thumb">
        <?php get_template_part('templates/content', get_post_format()); ?>
<?php endwhile?>


function equalHeight(group) {    
    tallest = 0;    
    group.each(function() {       
        thisHeight = $(this).height();       
        if(thisHeight > tallest) {          
            tallest = thisHeight;       
    group.each(function() { $(this).height(tallest); });

$(document).ready(function() {   

If thats no option, you could do sth. like that:


<div class="row">
        while (have_posts()) : the_post(); 
    <div class="col-sm-4 blog-post thumb">
        <?php get_template_part('templates/content', get_post_format()); ?>
        if($count == 3 || $count == 6 ) echo '</div><div class="row">';
Tuesday, November 1, 2022

First of all in your case the mergeTiff method should have a Document property, where you pass in the document you create once, because right at the moment you are creating several documents where each document contains all tiffs - at least the are all saved in result2.pdf.

Just to get you started (didn't test it and it clearly should be further optimized)...

public void btnExecute_Click(object sender, EventArgs e)
    strFolder = tbFolder.Text;  
    strDestination = tbDestination.Text;
    strFileArray = Directory.GetFiles(strFolder, "*.tif");

    // Create the PDF with the proper parameters (change as you please)
    iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);

    // Ensure the path to the folder is located where all the merged TIFF files will be saved as a PDF  
    iTextSharp.text.pdf.PdfWriter writer = 
       new System.IO.FileStream(strDestination + "/result2.pdf", System.IO.FileMode.Create));

    meregTiff(document, writer, strFileArray);


public void meregTiff(iTextSharp.text.Document document, iTextSharp.text.PdfWriter pdfWriter, string[] files)
// Load each tiff files and convert it into a BITMAP and save it as a PDF
// Recommendation: Use TRY/CATCH method to ensure any errors are handled properly...
foreach (string image in files)
        str = image.Substring(image.LastIndexOf("\"));
        bm = new System.Drawing.Bitmap(Server.MapPath("~/TiffImages" + str)); //modify this to ensure the file exists (can be same as the page_load method)
        total = bm.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
    catch (Exception ce) //getting error here... Parameter is invalid.

    iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;
    for (int k = 0; k < total; ++k)
        bm.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, k);
        iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bm, System.Drawing.Imaging.ImageFormat.Bmp);
        // scale the image to fit in the page 
        img.ScalePercent(72f / img.DpiX * 100);
        img.SetAbsolutePosition(0, 0);
Thursday, September 1, 2022

Updated 2018 for Bootstrap 4.0.0

The Bootstrap 4 animation transitions use transform, so I think it would be better to use translate to change the orientation to vertical, and the position of each slide...


.vert .carousel-item-next.carousel-item-left,
.vert .carousel-item-prev.carousel-item-right {
    -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);

.vert .carousel-item-next,
.vert .active.carousel-item-right {
    -webkit-transform: translate3d(0, 100%, 0);
            transform: translate3d(0, 100% 0);

.vert .carousel-item-prev,
.vert .active.carousel-item-left {
-webkit-transform: translate3d(0,-100%, 0);
        transform: translate3d(0,-100%, 0);

Vertical Carousel Demo

Tuesday, November 1, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages