Viewing 5 replies - 1 through 5 (of 5 total)
  • You are calling pagination function. But, does that exist? It is not a standard WP function. If you haven’t added that in your code, functions.php, then that is most likely your problem.

    Also, check this: https://codex.www.ads-software.com/Function_Reference/the_posts_pagination

    Thread Starter applenights

    (@applenights)

    So this is the function pagination is calling from my functions.php page:

    function pagination($pages = ”, $range = 4) {

    $showitems = ($range * 2) + 1;

    global $paged;

    if (empty($paged))

    $paged = 1;

    if ($pages == ”) {

    global $wp_query;

    $pages = $wp_query->max_num_pages;

    if (!$pages) {

    $pages = 1;

    }

    }

    if (1 != $pages) {

    echo “<div class=\”pagination\”>”;

    if ($paged > 2 && $paged > $range + 1 && $showitems < $pages)

    echo “« First“;

    if ($paged > 1 && $showitems < $pages)

    echo “‹ Previous“;

    for ($i = 1; $i <= $pages; $i++) {

    if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged – $range – 1) || $pages <= $showitems)) {

    echo ($paged == $i) ? “<span class=\”current\”>” . $i . “</span>” : “” . $i . ““;

    }

    }

    if ($paged < $pages && $showitems < $pages)

    echo “Next ›“;

    if ($paged < $pages – 1 && $paged + $range – 1 < $pages && $showitems < $pages)

    echo “Last »“;

    echo “</div>\n”;

    }

    }

    Should I make a code change here?

    the posted code is unreadable.

    please review about how to post code: https://codex.www.ads-software.com/Forum_Welcome#Posting_Code

    what actually is happening with the pagination?

    what theme are you using?

    does the theme have a specific template file for the front page?
    https://developer.www.ads-software.com/themes/basics/template-hierarchy/

    if so, what is the code of it?

    have you edited anything in your orignal theme?

    Thread Starter applenights

    (@applenights)

    The theme I used is called Clubber and no the template given was not set up as the demo provided… I’ve improvised quite alot. And sorry, I’ll place back-ticks around the code… here is the pagination function code again:

    
    function pagination($pages = ”, $range = 4) {
        $showitems = ($range * 2) + 1;
        global $paged;
        if (empty($paged))
        $paged = 1;
        if ($pages == ”) {
            global $wp_query;
            $pages = $wp_query->max_num_pages;
            if (!$pages) {
                $pages = 1;
            }
        }
    if (1 != $pages) {
            echo “<div class=\”pagination\”>”;
            if ($paged > 2 && $paged > $range + 1 && $showitems < $pages)
            echo “? First“;
            if ($paged > 1 && $showitems < $pages)
            echo “? Previous“;
            for ($i = 1; $i <= $pages; $i++) {
                if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged – $range – 1) || $pages <= $showitems)) {
                    echo ($paged == $i) ? “<span class=\”current\”>” . $i . “</span>” : “” . $i . ““;
                }
            }
        if ($paged < $pages && $showitems < $pages)
        echo “Next ?“;
        if ($paged < $pages – 1 && $paged + $range – 1 < $pages && $showitems < $pages)
        echo “Last ?“;
        echo “</div>\n”;
        }
    }
    
    • This reply was modified 8 years, 6 months ago by applenights.
    Thread Starter applenights

    (@applenights)

    Here is my home page (frontpage) code again:

    
    <?php get_header(); ?>
    
    <?php
        $page_layout = sidebar_layout();
        switch ($page_layout) {
            case "layout-sidebar-left":
            echo '<div class="sidebar-left">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '</div><!-- end .sidebar-left -->';
            break;
            case "layout-sidebar-right":
            echo '<div class="sidebar-right">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '</div><!-- end .sidebar-right -->';
            break;
            case "layout-full":
            echo '<div class="sidebar-right">';
            wz_setSection('zone-sidebar');
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-page'));
            echo '</div><!-- end .sidebar-right -->';
            break;
        }
    ?>
    	
    <div class="fixed">  
        <div class="col-blog-archive">
      
        <div class="title-caribbean"><h3><span style="color:#fff">UPCOMING</span> EVENTS</h3></div>
    
        <?php echo do_shortcode('[eventon_slider slider_type=\'carousel\' lan=\'L1\' orderby=\'ASC\' date_out=\'1\' date_in=\'1\' id=\'home_page_slider\' link=\'events_list\' skin=\'dark\' style_2=\'b\' cover=\'location\' ef=\'no\']');?>
      
        <br>
        <br>
      
        <div class="title-caribbean"><h3><span style="color:#fff">LATEST</span> BLOG POSTS</h3></div>
        <?php
            $query    = array(
                'post_type' => 'post',
                'paged' => $paged
            );
    
            $wp_query = new WP_Query($query);
            if (have_posts())
            while ($wp_query->have_posts()):
            the_post();
            $image_id     = get_post_thumbnail_id($post->ID);
            $cover_blog   = wp_get_attachment_image_src($image_id, 'blog-home');
    		$num_comments = get_comments_number();
            echo '
            <div class="blog-archive">';
            if ($image_id) {
                echo '
                <div class="blog-home-cover">
                <a href="' . get_permalink() . '">
                    <img src="' . $cover_blog[0] . '" alt="' . get_the_title() . '" />
                </a>
                </div><!-- end .blog-home-cover --> ';
            }
            echo '
            <h2 class="event-arc-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>
            <div class="blog-home-info">
                <p class="blog-user">' . get_the_author() . '</p> 
                <p class="blog-date">' . get_the_time('F jS, Y') . '</p> 
                <p class="blog-comment"><a href="' . get_comments_link() . '">';
    	    if ($num_comments == 0) {  
    	        echo '' . __('No comments', 'clubber') . '';  
    	    } elseif ($num_comments == 1) {  
    	        echo '' . __('One comment', 'clubber') . '';  
    	    } else {  
    	    echo '' .$num_comments . ' ' . __('comments', 'clubber') . '';  
            }
    	echo '</a></p> 
            </div><!-- end .blog-home-info -->
            <p>' . the_excerpt_max(200) . '...</p>
            <div class="blog-arc-more2"><a href="' . get_permalink() . '" rel="bookmark">' . __('Read more', 'clubber') . '</a></div>';
            echo '
        </div><!-- end .blog-archive -->';
        endwhile;
    ?>
    
    <div class="pagination-pos">
    <?php
        if (function_exists("pagination")) {
            pagination();
        }
    ?>
    </div><!-- end .pagination-pos -->								
    </div><!-- end .col-blog-archive -->   			 
    </div><!-- end .fixed -->
    
    <?php get_footer(); ?>
    

    The problem I am experiencing is whenever I click on the pagination number links, the posts stays the same. The url creates a page 2 parameter, but the posts still display the same.

    • This reply was modified 8 years, 6 months ago by applenights.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘My frontpage post pagination doesn’t work – need assistance with my code’ is closed to new replies.