I developed a site in WordPress where you can click on the featured image and title of the featured image and it should take you to the corresponding page same as if you would click on the nav item:

enter image description here

This was done using Custom Post Type UI that I called Quick Links:

enter image description here

I think I may have made this more complex than it needs to be though because when you click on one of the images or title the permalink takes you to yousite.com/quick-links/news instead of just yoursite.com/news

I am not sure if I should just gut the Custom Post Type UI, the source code for this page is this one at home-page.php:

   Template Name: Home Page

   // Advanced Custom Fields
   $quick_links_title   = get_field('quick_links_title');

get_header(); ?>

   <?php get_template_part('content','hero'); ?>

   <?php get_template_part('content','donate'); ?>

      <div class="container-fluid">
         <div class="row">
            <div class="col-md-8">
               <div class="panel panel-default">
                  <div class="panel-heading">
                     <h3 class="panel-title">Welcome to Three Green Birds!</h3>
                  </div><!-- panel-heading -->
                  <div class="panel-body">

                           <?php if (have_posts()) : ?>

                           <?php while (have_posts()) : the_post(); ?>

                              <!--<div class="spacer"></div>-->
                            <div class="post-title">
                     <?php if (function_exists('get_cat_icon')) get_cat_icon('class=myicons'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
                              <div class="spacer"></div>
                              <div class="post-content">
                              <?php the_content('Read the rest of this entry &raquo;'); ?>
                              <div class="spacer"></div>    
                              <div class="post-footer"></div>

                              <?php endwhile; ?>

                           <div class="navigation">
                              <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                              <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>

                        <?php else : ?>

                           <div class="post-title">Not Found</div>
                           <p class="post-content">Sorry, but you are looking for something that isn't here.</p>
                           <?php include (TEMPLATEPATH . "/searchform.php"); ?>

                        <?php endif; ?>

                        <!-- Quick Links
                        ======================================================== -->
                        <section id="quick-links">
                           <div class="container">
                              <h2><?php echo $quick_links_title; ?></h2>
                              <div class="row">

                                 <?php $loop = new WP_Query(array('post_type' => 'quick_links', 'orderby' => 'post_id', 'order' => 'ASC')); ?>
                                 <?php while($loop->have_posts()) : $loop->the_post(); ?>

                                 <div class="col-sm-3">

                                    <a href="<?php echo the_permalink(); ?>"><?php 

                                       if(has_post_thumbnail()) {


                                    <a href="<?php echo the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>
                                    <p><?php the_content(); ?></p>
                                 </div><!-- end col -->
                                 <?php endwhile; ?><!-- end of the loop -->
                                 <?php wp_reset_postdata(); ?>
                              </div><!-- row -->
                           </div><!-- container -->
                        </section><!-- quick-links -->

                  </div><!-- panel-body -->
               </div><!-- panel panel-default -->
            </div><!-- col-md-8 -->
            <!-- SIDEBAR 
               ====================================================================== -->
            <div class="col-md-4">
               <?php if (is_active_sidebar('sidebar')) : ?>
                  <?php dynamic_sidebar('sidebar'); ?>
               <?php endif; ?>
            </div><!-- col-md-4 -->
         </div><!-- row -->
      </div><!-- container-fluid -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>

If I were to gut the Custom Post Type UI, could I still use the code above to get the browser to render what you see above, the quick-links title notwithstanding since that is a variable so I am not sure that would appear if I am no longer using the Quick Links Custom Post Type.

So to be clear I just want the user to click on the News image or text and have the user be taken to mysite.com/news and not mysite.com/quick-links/news.

I believe the problem is here:

<?php $loop = new WP_Query(array('post_type' => 'quick_links', 'orderby' => 'post_id', 'order' => 'ASC')); ?> 

I get mysite.com/quick-links/news when I hover over the featured images and title of the featured image, but I just want it to go to mysite.com/news as if I were clicking on the news item in the nav menu. So what I did was edit the $loop I am using so that the site no longer displays mysite.com/quick-links/news but just mysite.com/news. I changed the $loop from:

<?php $loop = new WP_Query(array('post_type' => 'quick_links', 'orderby' => 'post_id', 'order' => 'ASC')); ?> 


<?php $loop = new WP_Query(array('post_type' => 'page', 'orderby' => 'post_id', 'order' => 'ASC')); ?> 

but now the Quick Links section of the home page wants to display all the pages and not just news, about us and get involved. Any ideas on how to query only those three specific pages?

2 Answers 2


I learned that in the WP Query I had to specify page instead of quick_links which was the custom post type. In fact I completely removed the Custom Post Type UI and the plugin. It was all completely unnecessary.

I did not want every single page, just the news, about us and get involved so I researched if there was a way to grab specific pages, namely, those with a featured image and in the correct order and from what I found online I was able to piece together this code:

<?php $loop = new WP_Query(array('post_type' => 'page', 'meta_key' => '_thumbnail_id', 'order' => 'asc')); ?>

and it works:

enter image description here


first off you are using echo the_permalink()

<a href="<?php echo the_permalink(); ?>"><?php 
  if(has_post_thumbnail()) {

you don't have to echo out permalink

<a href="<?php the_permalink(); ?>"><?php 
  if(has_post_thumbnail()) {

carefully read the https://codex.wordpress.org/Using_Permalinks codex part in wordpress site

Also if you are using multiple loops in the page use wp_reset_query(); after or before the loop. And be sure to review your query arguments. For example:
where is the query for contents after <h3 class="panel-title">Welcome to Three Green Birds!</h3>.
take reference for wp queries from WP_Query and query_posts

  • Hi Regolith, I utilized wp_reset_postdata() to restore the global $post variable of the main query loop after the secondary query loop using new WP_Query. I am not sure you are answering my question, but more pointing out other things that are wrong with my code. The issue seems to be somewhere here: <?php $loop = new WP_Query(array('post_type' => 'quick-links', 'orderby' => 'post_id', 'order' => 'ASC')); ?> 'quick-links' is the post_type I have and that's why it goes to mysite.com/quick-links/news instead of just mysite.com/news. How to fix that is my question.
    – Daniel
    Jul 5, 2017 at 16:38

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.