WordPress.org

Ready to get started?Download WordPress

Forums

pagination help needed please (1 post)

  1. antistandard
    Member
    Posted 3 years ago #

    Hello,

    I have a function that displays all posts in a category.
    I can't get pagination to work and I have tried everything.
    If you can help me I would be very appreciative and if not I will then seek a way to pay someone to help as this is just taking way to long to do something fairly simple.
    thank you.
    code:

    FUNCTION CALLING PAGE:
    <?php list_advertisers_business(); ?>

    FUNCTION THAT GETS CALLED:

    function list_advertisers_business() {
    $cats = get_categories('include=7');
    echo '<ul class="cat-list">';
      foreach($cats as $cat) :
        //only loop through categories which have subcategories
        if( get_categories('parent='.$cat->term_id) ) :
    	$cat_name=$cat->slug;
        echo '<ul>';
    	  // get the direct sub categories
    	  $sub_cats = get_categories('parent='.$cat->term_id);
    	    foreach($sub_cats as $sub_cat) :
    		$sub_cat_name=$sub_cat->slug;
    		echo ' <div id="category-header">' . $sub_cat->name; ?></div><?
    		// get all posts with that category
            $cat_posts = get_posts('category_name='.$sub_cat_name);
              foreach($cat_posts as $post) :
              setup_postdata($post);
               ?>
                <div id="query">
    			<div class="advertiser-table">
    			<h2 class="advertiser-name"><? $Company = get_post_meta($post->ID, 'Company', true); if($Company != ''){ echo $Company; } ?></h2>
    			<span class="advertiser-details">
    						<? require 'data-table.inc'; ?>
    			</span>
    			</div>
    			</div>
    			<?
              endforeach; // closes 'foreach($cat_posts as $post)'
    		endforeach; // closes 'foreach($sub_cats as $sub_cat)'
    		echo '</ul></li>';
    	endif;
      endforeach; // closes 'foreach($cats as $cat)'
    echo '</ul>';
    }

    Thank you
    James

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags