• I would like to add links to the slider on this website – https://www.drblen.com.

    Here is the code that the template uses for the slider:

    <?php $limittext = $limit;?>
    <?php global $more;	$more = 0; $counter=1;?>
    <?php query_posts("posts_per_page=5&post_type=slider");?>
    <?php if(have_posts()) { ?>
    <ul class="kwicks horizontal">
    	<?php while (have_posts()) : the_post(); ?>
    
    		<?php
    			$custom = get_post_custom($post->ID);
    			$custom = get_post_custom($post->ID);
    			$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'slider-post-thumbnail' );
    			$url = $thumb['0'];
    			$thumb = $custom["thumb"][0];
    			$sliderurl = $custom["slider-url"][0];
    		?>
    
    		<li><span class="shadow"></span>
    			<?php echo '<div class="thumb">'; ?>
    				<div class="bg" style="background-image:url(<?php echo $url; ?>)" ></div>
    			<?php echo '</div>'; ?>
    
    			<div class="desc color-<?php echo $counter; ?>">
    				<div class="left-bg">
    					<a href="<?php the_permalink(); ?>" class="left-bg"><?php the_title('<h2>','</h2>'); ?></a>
    					<div class="excerpt">
    						<?php the_excerpt();  ?>
    					</div>
    					<a href="<?php the_permalink(); ?>" class="kwick-button">read more</a>
    				</div>
    			</div>
    
    		</li>
    	<?php $counter++; endwhile; ?>
    	<?php wp_reset_query(); ?>
    </ul>
    <?php } else { ?>
    		<div id="attention-box">
    			<div id="att-box-inner">
    			<div class="attention-box alert-box" style="margin: 150px 20px 0 20px;">You don't have any <strong>Slides</strong>. You need to create them using <strong>Slides</strong> custom post type.</div>
    			</div>
    		</div>
    	<?php } ?>
    <?php wp_reset_query();?>

    Any help would be greatly appreciated. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    What links do you want to add and how would they look? I see the title and read more links below the images, what else should there be?

    Thread Starter dunbicake

    (@dunbicake)

    My client wants the images themselves to be hyperlinked as well. He knows the other links are there, but really wants the images to be clickable.

    Any ideas?

    I’ve tried a few things to know avail.

    Moderator bcworkz

    (@bcworkz)

    Seems like a reasonable request. Normally, you would use get_the_permalink() to get the link into a variable, then extract the link text and replace it with an image. Except there’s no image there and there’s nothing to click on. The image we see is a background element, which allows the slider to quickly and smoothly alter the image limits seen.

    You will need to use javascript or jQuery (jQuery would be way easier for this) to see the click event and “click” the link on the user’s behalf. To pass the post/page ID to javascript, add an id attribute to the element the click listener is attached to via template script. Onclick, extract the ID from the element id value then do window.location = 'index.php?p=' + post_id;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Slider links in php’ is closed to new replies.