error link category to wordpress

Question

i have POST and category and i have ep

i want get link POST in the post ep

http://localhost/POST/

<?php
// Get BG
foreach (get_the_category() as $category) {
    if ($category->name != 'ep') {
        $mycategory = $category->name;
        $mycategoryID = $category->term_id;

        // Do What I said
        global $wpdb;
        $postID = $wpdb->get_row("SELECT * FROM demo_posts WHERE post_title = '" . $mycategory . "' ");
        $mycategory_link = get_permalink( $postID->ID );



        $postID->ID;


    }
}
$ActiveepID = get_the_ID();
?>


<h3><?php the_title();?> | <a href="<?php echo esc_url($mycategory_link);?>"><?php echo $mycategory;?></a></h3>

Sometimes it brings the correct link, and most of the time I do not know the cause of the error

This Link error
http://localhost/3326-revision-v1/

This Link true
http://localhost/POST

and sorry for my bad language

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/error-link-category-to-wordpress/">

error link category to wordpress</a>
0
user4158643 3 months 0 Answers 29 views 0

Leave an answer