I created a special template for my custom post type that is called "Portfolio" that includes a custom WP_Query for the custom post type "portfolio"... It seems that the posts are working fine but the link to the single page listing of the custom post type item does not appear but instead it redirects me to the "example.com/work" where I list all my costum post items.

Is there any solution to this ? Did I miss something ?

Here's is my full code :

<div class="jumbotron">

                $args = array(
                    'post_type' => 'portfolio',
                    'posts_per_page' => 3   

                $portfolio = new WP_Query($args);

                while($portfolio->have_posts()) : $portfolio->the_post(); 
                    <?php get_template_part('content', get_post_format());?>


                <?php wp_reset_postdata(); ?>

And for the content page that lists each item :

 <div class="card p-3">  <?php if(has_post_thumbnail()){

 ?><a href="<?php esc_url(get_permalink()); ?>"><?php the_title() ?></a>

<blockquote class="blockquote mb-0 card-body">
<?php the_content() ?>

<small><?php the_category() === null ? : the_category(); ?></small>


1 Answer 1


You missed and echo on <a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title() ?></a>

  • I can't believe this is the problem ! Thanks a lot !
    – eljh
    Mar 18, 2018 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.