• Hello guys, I am having some issues with my wordpress site.

    When one clicks on a permalink element, WordPress generates a page full of all the custom fields.

    How do I get it to only show the one that I click on? I have tried to get it to work but I am at an impasse.

    This code is the clickable custom work image field
    <?php

    $args = array(
    ‘post_type’ => ‘work’
    );

    $the_query = new WP_Query($args);
    ?>

    <?php if (have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    ‘>

    • <img class=’image-area’ src='<?php the_field(‘image’); ?>’>
    • <?php endwhile; ?>
      <?php wp_reset_postdata(); ?>
      <?php endif; ?>

      When I click on the image it displays all the work posts not the one that was clicked,

      I cannot find out how to fix it!

      Sorry about the code blocks I could not get it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Please use display editor of adding CODE, your code is breaking this page.

    Thread Starter Loki180

    (@loki180)

    Sorry about the above, This one will be better to understand!

    The blow code is from the

    single-work.php

    $args = array(
        "post_type" => "work"
      );
    
      $the_query = new WP_Query($args);
    ?>
    
    <?php if (have_posts() ) : while ($the_query->have_posts() ) : $the_query->the_post(); ?>
    
    <h1><?php the_field("name_of_website"); ?></h1>
    <img class="image-area' src="<?php the_field("image"); ?>'>
    <p><?php the_field("description"); ?></p>
    
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>

    The below code is from the portfolio of the clickable field image

    <?php
    
                  $args = array(
                    'post_type' => 'work'
                  );
    
                  $the_query = new WP_Query($args);
                ?>
    
                <?php if (have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
                  <a href='<?php the_permalink(); ?>'>
                    <li>
                      <img class='image-area' src='<?php the_field('image'); ?>'>
                    </li>
                  </a>
    
                <?php endwhile; ?>
                <?php wp_reset_postdata(); ?>
                <?php endif; ?>

    When I click on the image WordPress displays all the custom posts and fields from Work I want it to only display the one clicked, I can not remember how to do it!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Single permalink returning one custom post’ is closed to new replies.