I created a relational custom field (slide_link) to link my slides to pages, but i am having difficulty applying the link to my slider button in the home.php file. Here are my codes:
<div class="flexslider">
<ul class="slides">
<?php
$query = new WP_Query( array('post_type' => 'slide') );
while ( $query->have_posts() ) : $query->the_post();
?>
<?php
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' );
$url = $thumb['0'];
?>
<?php
global $post;
$meta = get_post_meta( $post->ID );
$captn = isset( $meta['caption'][0] ) ? filter_var( $meta['caption'][0], FILTER_SANITIZE_STRING ) : '';
$slideurl = isset( $meta['slide_link'][0] ) ? filter_var( $meta['slide_link'][0], FILTER_SANITIZE_STRING ) : '';
?>
<li data-thumb="<?php echo $url; ?>">
<img src="<?php echo $url; ?>" />
<p class="flex-caption"> <?php echo($captn); ?> </p>
<a href="<?php echo $slideurl; ?>" class="flex-link">See More</a>
</li>
<?php endwhile; ?>
</ul>
</div><!-- /home banner -->
Function.php where I registered the custom field
//function to register vision field
add_filter('the_permalink', 'getCustomFeature6');
function getCustomFeature6($slideurl) {
global $post;
$meta = get_post_meta($post->ID, 'slider_link', true);
return $slideurl;
}
Any help would be appreciated!
I do not understand why are you using add_filter('the_permalink', 'getCustomFeature6');
. I would use this:
<?php $slideurl = get_post_meta($post->ID, "slider_link", true); ?>
<li data-thumb="<?php echo $url; ?>">
<img src="<?php echo $url; ?>" />
<p class="flex-caption"> <?php echo($captn); ?> </p>
<a href="<?php echo $slideurl; ?>" class="flex-link">See More</a>
</li>