0

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">

            <?php
                $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
                endwhile;

                    ?>
                </div>
                <?php wp_reset_postdata(); ?>

And for the content page that lists each item :

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

   the_post_thumbnail(array(200,200));
 }
 ?><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>

</blockquote>

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 '18 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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