I create a page in wordpress series.php
and here it the code where I block!
<?php
$categories=get_categories(
array( 'parent' => $cat->cat_ID)
);
foreach ($categories as $c) {
// what you really want instead of var_dump is something to
// to create markup-- list items maybe, For example
$idp = $c->term_taxonomy_id;
//then i get the data from the database
$cat_data = get_option("category_".$idp);
?>
<div class="wide-box">
<!-- Content Detail Box -->
<a href="<?php echo get_category_link( $idp ); ?>" class="wb-image"><img src="<?php echo $cat_data['original_img']; ?>"></a>
<!-- Wb Center -->
<div class="wb-center">
<h3 class="wb-name"><a href="<?php echo get_category_link( $idp ); ?>"><?php echo $c->name; ?></a></h3>
<div class="wb-details">
Genres : <?php echo $cat_data['genres']; ?><br>
Country : <?php echo $cat_data['country']; ?><br>
Language : <?php echo $cat_data['language']; ?><br>
Year : <?php echo $cat_data['year']; ?>
</div>
<div class="latest-label">Latest Episode:</div>
<?php
$catquery = new WP_Query( 'cat='.$idp.'&posts_per_page=1' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<a href="<?php the_permalink() ?>" class="latest-ep"><?php the_title(); ?></a>
<?php endwhile; ?>
</div>
<!-- Wb Center -->
</div>
<?php
}
?>
</div>
So how to add paging for loop to show it?
I create a page in wordpress series.php
and here it the code where I block!
<?php
$categories=get_categories(
array( 'parent' => $cat->cat_ID)
);
foreach ($categories as $c) {
// what you really want instead of var_dump is something to
// to create markup-- list items maybe, For example
$idp = $c->term_taxonomy_id;
//then i get the data from the database
$cat_data = get_option("category_".$idp);
?>
<div class="wide-box">
<!-- Content Detail Box -->
<a href="<?php echo get_category_link( $idp ); ?>" class="wb-image"><img src="<?php echo $cat_data['original_img']; ?>"></a>
<!-- Wb Center -->
<div class="wb-center">
<h3 class="wb-name"><a href="<?php echo get_category_link( $idp ); ?>"><?php echo $c->name; ?></a></h3>
<div class="wb-details">
Genres : <?php echo $cat_data['genres']; ?><br>
Country : <?php echo $cat_data['country']; ?><br>
Language : <?php echo $cat_data['language']; ?><br>
Year : <?php echo $cat_data['year']; ?>
</div>
<div class="latest-label">Latest Episode:</div>
<?php
$catquery = new WP_Query( 'cat='.$idp.'&posts_per_page=1' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<a href="<?php the_permalink() ?>" class="latest-ep"><?php the_title(); ?></a>
<?php endwhile; ?>
</div>
<!-- Wb Center -->
</div>
<?php
}
?>
</div>
So how to add paging for loop to show it?
Add this argument to your WP_Query.
'paged' => get_query_var( 'paged' ),
And use a array style of arguments rather than a query post style.
you can used the paginate_links()
function along with the paged parameter in your query.
<?php
$categories=get_categories(
array( 'parent' => $cat->cat_ID)
);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Get current page or set to 1 if not set
foreach ($categories as $c) {
// what you really want instead of var_dump is something to
// to create markup-- list items maybe, For example
$idp = $c->term_taxonomy_id;
//then i get the data from the database
$cat_data = get_option("category_".$idp);
?>
<div class="wide-box">
<!-- Content Detail Box -->
<a href="<?php echo get_category_link( $idp ); ?>" class="wb-image"><img src="<?php echo $cat_data['original_img']; ?>"></a>
<!-- Wb Center -->
<div class="wb-center">
<h3 class="wb-name"><a href="<?php echo get_category_link( $idp ); ?>"><?php echo $c->name; ?></a></h3>
<div class="wb-details">
Genres : <?php echo $cat_data['genres']; ?><br>
Country : <?php echo $cat_data['country']; ?><br>
Language : <?php echo $cat_data['language']; ?><br>
Year : <?php echo $cat_data['year']; ?>
</div>
<div class="latest-label">Latest Episode:</div>
<?php
$category_query = new WP_Query( array(
'cat' => $idp,
'posts_per_page' => 1,
'paged' => $paged
) );
while($category_query->have_posts()) : $category_query->the_post();
?>
<a href="<?php the_permalink() ?>" class="latest-ep"><?php the_title(); ?></a>
<?php endwhile; ?>
</div>
<!-- Wb Center -->
</div>
<?php
}
// Pagination
echo paginate_links( array(
'total' => $category_query->max_num_pages
) );
?>
</div>