• Hello,

    I need to be able to deactivate the single link on SOME posts. I know how to disable all links. But thats not what iam looking for.

    Iam looking for a solution to add a checkbox or a custom field or a plugin to have the option to disable the link on selected posts.

    But i have no clue how…

    Thank you for your time

Viewing 6 replies - 1 through 6 (of 6 total)
  • C W (VYSO)

    (@cyril-washbrook)

    What exactly do you mean by “the single link”? I suspect it will also be useful to know what theme you are using.

    Thread Starter heller247

    (@heller247)

    Its a custom theme.

    With single link i mean the links to reach the single view.

    you can check it here: https://www.pesch-partner.de/?page_id=275

    They are added via css and that snippet:

    <div id="linky">
    
      <?php
          $linksPosts = new WP_Query();
          $linksPosts->query('showposts=7&cat=335');
      ?>
      <?php while ($linksPosts->have_posts()) : $linksPosts->the_post(); ?>
      <div class="boxy">
        <div class="read">
    
    <br>
    <?php the_post_thumbnail( $size, $attr ); ?> <br><br>
    
    <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
         <span class="newstext"> <?php the_content('Read the rest of this entry &raquo;'); ?></span>
        </div>
      </div>
      <?php endwhile; ?>
    
    </div>

    Some of those posts should not have a link in the Title. And iam looking for a solution to add an option in the posts to disable a link in the title.

    C W (VYSO)

    (@cyril-washbrook)

    You can use a custom fields plugin like this one, then add an if statement to your template. A plugin is not strictly needed, but if you have no idea about these things, it will be much easier if you use a plugin.

    If you use this plugin, you could create a true/false field with a field name such as no_link_to_single. Then you would edit the following line:

    <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>

    You could change it to something like this:

    <?php
       var_dump( get_field('no_link_to_single') );
       if( get_field('no_link_to_single') ) { ?>
          <h4><?php the_title(); ?></h4>
       <?php } else { ?>
          <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
       <?php } ?>

    Thus, when the field is selected, no link will be shown. (I do not personally use this plugin. If you have any problems, make sure to read the plugin documentation.)

    Thread Starter heller247

    (@heller247)

    Wow its working!

    Thank you so much!

    Only small problem is that here is now a litte Text above the Link with

    bool(false) or if activated with bool(true)

    Can i somehow hide it?

    Thread Starter heller247

    (@heller247)

    ok nevermind i just got rid of that line

    var_dump( get_field('no_link_to_single') );

    you saved my day! thank you again

    C W (VYSO)

    (@cyril-washbrook)

    Sorry yes, I should have mentioned that var_dump is just a testing/debugging tool. Glad to see that you have worked everything out.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable Single Links on selected posts’ is closed to new replies.