Saturday, September 17, 2022
HomeWordPress DevelopmentGet permalink in customized submit sort loop would not work

Get permalink in customized submit sort loop would not work


I am unable to wrap my head round this and sure I’ve tried to flush the permalinks and so on…

I’ve by no means encountered this earlier than and per week in the past it labored – I’ve not modified any code and it really works on one other web site with the very same theme.

anyway, I’ve just a few customized submit sorts and the issue is affecting all of those.

For instance, let’s take information.

In single-news.php I’ve an inventory displaying the most recent 10 information.

<?php
            $question = new WP_Query(array(
            'post_type' => 'information',
            'post_status' => 'publish',
            'posts_per_page' => 10,
            'post__not_in' => [get_the_ID()],
            ));
                
            whereas ($query->have_posts()) {
                $query->the_post();

                $newspost="<li><a href="".get_permalink(get_the_ID()).'">'.get_the_title().'</a></li>';

                echo $newspost;
                
            }
            wp_reset_query();

The title works, get_the_ID() reveals the right submit ID if I echo it, however the URL simply returns website.com/information and never the url to the submit.

For an additional submit sort, companies, it simply returns website.com/companies

What’s improper right here? I am positive it isn’t the code, and I’ve tried deactivating plugins as effectively with no luck.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments