I have a wordpress website where I make a webcomic, and I want to add a second webcomic using the same domain. When an end user is reading one comic or the other, and clicks the next page button, I want it to link to the next page in that category. So if Webcomic 1 is Category ID 01, then I want it to continue on with Category ID 01
I also want a first page, and last page button for each webcomic. So if Webcomic 01 is Category ID 01, I want it to bring me to the first page of Category ID 01, similarly, if you're reading Webcomic 02, with ID 02, I want the first page button to bring you to the first page of Category 02
<?php //gets current categories of the post you're looking at inside wordpress loop as an array:
$cats = get_the_category();
//you could then query + filter the posts using the first result from that array
//(if you're not doubling up and categorizing things as more than one category)
$args = array(
'numberposts' => 1,
'orderby' => 'post_date',
'order' => 'ASC',
'fields' => 'ids',
'category' => $cats[0]["term_id"]
);
$post_cus = get_posts($args);
$first_post_id = $post_cus[0];
$post_url = get_the_permalink ($first_post_id); ?>
<div class="pagenavigation">
<div class="col1">
<a href="<?php echo .$post_url; ?>"> First Page </a>
</div>
<div class="col2">
<?php previous_post_link('%link', '%title', TRUE); ?>
</div>
<div class="col3">
<?php next_post_link('%link', '%title', TRUE); ?>
</div>
<div class="col4">
<a href="https://website.com/latest">Last Page</a>
</div>
</div>
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content/content-single' );
?>
<div class="pagenavigation">
<div class="col1">
<a href="https://website.com/00/">First Page</a>
</div>
<div class="col2">
<?php previous_post_link('%link', '%title', TRUE); ?>
</div>
<div class="col3">
<?php next_post_link('%link', '%title', TRUE); ?>
</div>
<div class="col4">
<a href="https://website.com/latest">Last Page</a>
</div>
</div>
<?php
endwhile; // End of the loop.
get_footer();
I tried copy pasting code from two separate stack exchange answers in hopes of trying to create the results I want. I specifically looked at Add PHP variable inside echo statement as href link address? to call the code for the button, and then tried https://wordpress.stackexchange.com/questions/363822/how-can-you-get-first-post-last-post-and-post-count-in-a-category but couldn't quite figure out how to get the category dynamically.
I tried to use this: How i can get the first post of current category and echo the link? Which almost seemed like the answer, but I couldn't figure out how to call the function in my post.