Some images are missing the navigation arrows

Clicking on the images here reveals 'next' and 'previous' arrows on each image, except the first two. What could be causing this issue?

<nav class="prev-next">
    <ul>
    <?php
    $next_post = get_next_post();
    $prev_post = get_previous_post();
    $next_post_year = '';
    $previous_post_year = '';
    $previous_post_media = '';
    $next_post_media = '';
    if($next_post) {

    $next_post_id  = ($next_post->ID);
    $years = wp_get_post_terms( $next_post_id, 'years', array( 'fields' => 'ids' ) );
    $medias = wp_get_post_terms( $next_post_id, 'media', array( 'fields' => 'ids' ) );
    $next_post_year = $years[0];
    $next_post_media = $medias[0];

    }
    if($prev_post) {
    $previous_post_id  = ($prev_post->ID);
    $years = wp_get_post_terms( $previous_post_id, 'years', array( 'fields' => 'ids' ) );
    $medias = wp_get_post_terms( $previous_post_id, 'media', array( 'fields' => 'ids' ) );
    $previous_post_year = $years[0];
    $previous_post_media = $medias[0];

    }
    $show_next = false;
    if($next_post_year == $current_post_year && $next_post_media == $current_post_media) {
        $show_next = true;
    }
    $show_prev = false;
    if($previous_post_year == $current_post_year && $previous_post_media == $current_post_media) {
        $show_prev = true;

    }
    ?>
        <?php /*<li class="prev"><?php previous_post('%', '&lsaquo; Previous', 'no'); ?></li>
        <li class="next"><?php next_post('%' , 'Next &rsaquo;', 'no'); ?></li>*/ ?>
        <?php if($show_next) { ?>
        <li class="prev"><?php next_post('%' , '&lsaquo; Previous', 'no'); ?></li>
        <?php } ?>
        <?php if($show_prev) { ?>
        <li class="next"><?php previous_post('%', 'Next &rsaquo;', 'no'); ?></li>
        <?php } ?>      
    </ul>
</nav>

Inspecting the code of the single image pages not displaying arrows shows that the next and previous <li> elements are not being generated on those specific pages.

Answer №1

element, you won't find any created
  • because it doesn't meet the condition: . The purpose of this condition is to check if the years are matched: if($next_post_year == $current_post_year). It's important to reassess whether this condition is truly necessary.

  • Similar questions

    If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

    What are the essential Angular 2 observables for me to utilize?

    I have created a form input for conducting searches. Upon user input into the search bar, I want to trigger calls to two separate APIs simultaneously. Here is my current attempt: myInput: new FormControl(); listOne: Observable<string[]>; listTwo: Ob ...

    Utilizing Vue.js: Dynamically linking v-model to route parameters depending on the current state

    I'm currently in the process of developing an application that will serve as the backbone for a restaurant chain's website. The main functionality involves allowing users to modify page content and images. Given the complexity of the site with it ...

    Issues with updating web pages on Google Chrome

    Having an issue with Google Chrome not updating the new CSS on my website without clearing the cache every time. It's a concern because we can't expect visitors to constantly clear their cache when visiting. Does anyone have a solution for ensuri ...

    Unlocking the Power of Transition: Effortlessly Submitting a Form Post

    After the modal finishes fading out, I want my form to be submitted and sent to the email file "refreshform.php". However, currently after the modal fades out, the form does not submit or post anything to the PHP file for sending the email. It simply fades ...

    What's the best way to ensure that your item list automatically updates the rendered list when an item is deleted

    I've developed a web cart using Redux. The cart functions as expected, except for one issue - when I delete an item from the cart, the changes are only displayed after refreshing or navigating to another page. How can I update the view dynamically as ...

    Combine angular ui router templates using grunt into a single file

    Currently, I am working on an angular-ui-router project that consists of 150 files scattered all over. My goal is to create a grunt task that will merge all these files into a single index.html file structured like this: <script type="text/ng-template" ...

    Populating HTML input field with AJAX response

    One challenge I am facing involves a dropdown menu containing Course Titles sourced from a database in the index.php file. After capturing the selected data from the dropdown, I transmit it to a PHP file. In this PHP file, using the received Course Title, ...

    Why does the shadow in Three.js only appear in a limited region?

    I brought in a model and noticed that the shadow is only visible in a small area (highlighted in green in the image). How can I make all objects display their shadows? https://i.sstatic.net/hmzp2.png Below is my code snippet. light = new THREE.Direction ...

    CSS - Guidelines for Targeting Multiple Elements

    My CSS code includes several commands that target similar elements, but the resulting design appears messy. I am seeking advice on a more effective way to select these elements in a conventional manner. Despite consulting documentation, I have resorted to ...

    ui-router: Converting URL parameters

    Is there a way to seamlessly transform URL parameters? Let me illustrate with a scenario. Our URL structure is like this: /shopping/nuts/:productId /shopping/berries/:productId /shopping/juice/:productId The products in our app, fetched from an API, may ...

    Using React Bootstrap, you can ensure that only a single collapse opens at a time when rendering it with a map function. This allows you to display

    When a user clicks on the "View Tasks" button, I want to display the relevant tasks specific to that user. However, currently all React Bootstrap Collapse Components open up and show tasks for every user instead of just one. This issue arises because the o ...

    There seems to be an issue with the AJAX REST call failing to transmit data

    Whenever I attempt to submit the form, the page refreshes and nothing gets saved in the database. The code in subforum.js $(document).on('click','#submit',function(e) { var user = JSON.parse(sessionStorage.getItem("ulogovan")); consol ...

    Why does my ball defy the laws of geometry and refuse to be perfectly round with

    I'm attempting to create a simple game in javascript, but I've run into an issue where my circle isn't perfectly round. Despite searching for solutions online for 20 minutes, I haven't been able to resolve the problem. I'm hoping s ...

    Having difficulty communicating with the smart contract using JavaScript in order to retrieve the user's address and the balance of the smart contract

    Hi there, I am a newcomer to the world of blockchain technology. Recently, I created a smart contract designed to display both the contract balance and user data, including the address and balance of the user. The smart contract allows users to deposit fun ...

    Generate random unique values from an array to populate a text input field in HTML. Display a message once all unique values have been shown

    I have included an option code and text box below: <select id="sel" class="form-control input-lg" data-live-search="true"> <option value="">-- Choose Your Country--</option> </select><br/><br/><br/> &l ...

    Retrieve the original content of a file uploaded by a user in Node.js using Express

    Can we extract the raw file contents from a user uploaded file using Node.js Express? app.post('/images', upload.single('image'), async (req, res) => { const file = req.file ... I have come to realize that the file variable in t ...

    What is the appropriate content-type to use when sending AJAX POST data?

    Having an issue sending base64 image data using ajax post. I suspect the problem lies with the Content-Type value, as I have tried using application/json, text/json, and image/jpeg without success. Javascript function sendFormData(fD) { var urls = fD ...

    Using Bootstrap to Implement Special CSS Styles for Various Devices

    Is there a way to implement specific CSS rules for different screen sizes using bootstrap? For example, on medium screens (md), can we set an element's left-margin to 10px and have it be 100px on small screens (sm)? Any guidance would be appreciated. ...

    What's the best way to combine cells using HTML, CSS, and PHP?

    Can anyone assist me with merging cells containing identical values in specific columns? <td style="text-align: center; font-size: 9.5px;">{{$endereco->quadra}}</td> <td style="text-align: center; font-s ...

    How to leverage WordPress add_rewrite_rule with regex positive lookahead

    Summarized: Do WordPress add_rewrite_rule functions support positive lookaheads in regex? I have one detailed below that seems valid but doesn't work. Can a WordPress custom post type post slug be rewritten so multiple posts can have the same name b ...