Question

This href I have on a page is included in a cycle 2 slider so a caption under an image. BUT it doesn't work when clicking and it opening a new tab, it only works when you right click and then click "go to ....". Does anyone know why?

The plugin on wordpress: http://www.advancedcustomfields.com/

Code: <a class="alt-caption" href="http://<?php the_field('url_site'); ?>"><?php the_field('url_site'); ?></a>

      <div class="paginawrap no_overflow">
        <div class="wraptest">
          <div class="cycle-slideshow" 
               data-cycle-fx="carousel" 
               data-cycle-speed="500" 
               data-cycle-delay=5000
               data-cycle-next=" > img"
               data-cycle-caption=".alt-caption"
               data-cycle-caption-template="{{alt}}"
               data-cycle-carousel-fluid=true
               data-allow-wrap=false
          >
<?php $args = array(
        'post_type' => 'project',
        'posts_per_page' => 10
      );
        $query = new WP_Query( $args );
        if ( $query->have_posts()) :
        while ( $query->have_posts()) :  $query->the_post();
          the_post_thumbnail('home');
        endwhile; wp_reset_postdata();
        endif; ?>

         <a href=" http://<?php the_field('url_site'); ?> "> <div class="alt-caption"></div></a>
          </div>
          <div class="archief1">

          </div>
        </div>
      </div>
Was it helpful?

Solution

Your href is empty. Let's have a look at your source code:

<a class="alt-caption external" href="http://">www.aimassociates.nl</a>

The href attribute is looking at "http://".

Maybe you must add an echo?

<?php echo the_field('url_site'); ?>

It's weird that the same PHP code returns different result, have you copy/paste the code just as is in your files?

Why don't you try this?

<?php $site_url = the_field('url_site'); ?>
<a class="alt-caption" href="http://<?php echo $site_url; ?>"><?php echo $site_url; ?></a>

OTHER TIPS

You use php to load the link. Why not use php the entire way for that line of code? Something like this:

echo('<a class="alt-caption" href="' . $the_field . '" target="_blank"><' . $the_field . '></a>');

Also make sure that your homepage correctly reads the php data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top