Reputation: 117
I am trying to get the link from the database in WordPress and user should direct to that link on a single click.
I have almost achieved everything but there is one weird problem I am facing.
In my custom php file I have this code.
<div style =" margin-bottom: 40px; "><div><li><a href="<?php echo $array_var ?>">
<?php echo get_the_post_thumbnail( $post_id, 350,'' ); ?></br><h2><?php the_title(); ?></h2></a><?php echo get_the_excerpt();?></li></div></div>
Here ahref tag is coming as "website custom page link/database-link". Whereas at other places it is coming only as link from the database (which is the correct case for me.)
I will explain it little more.
<?php $query = new WP_Query( array(
'post_type' => 'post',
'category_name' => 'Trending',
'posts_per_page' => 8
) );
$i=0;
while ($query->have_posts()) : $query->the_post();
$post_id= $query->post->ID;
$array_var=$link_array[$i];
**echo $array_var;**
?>
<ul>
<div style =" margin-bottom: 40px; "><div><li>**<a href="<?php echo $array_var ?>">**
<?php echo get_the_post_thumbnail( $post_id, 350,'' ); ?></br><h2><?php the_title(); ?></h2></a><?php echo get_the_excerpt();?></li></div></div>
<?php
$i++;
endwhile; ?>
</ul>
I have marked two places in the code in asterisk. Both have same code but behaviour is different. At first place I am getting link as, say, www.google.com and at second place I am getting it as /www.google.com.
I want it to be www.google.com only.
For reference, the corresponding page is www.coolfuzz.com, you can see that in the first row above every thumbnail is the correct link(which is not clickable btw) but thumbnail has incorrect link.
Please tell me how to correct this?
Upvotes: 0
Views: 31