Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Echo problem in wordpress environment

    Hi all,

    I'm having a little problem getting an 'echo' to work. The code below works but it shows as domain.com/<?php the_permalink() ?> instead of rendering the URL. I think I have may be missing a single or double quote but not sure.

    Here is my code:

    Code:
    	<ul>
    	<?php $my_query = new WP_Query('showposts=3&offset=1&cat=1'); ?>
    	<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <?php // Generates alternate tile for boxes
    	$title = get_post_meta($post->ID, "custom-title-value", true);
    	if ($title != "") {
    	echo '<li><a href="<?php the_permalink() ?>">'.$title.'</a></li>';
    	} else { ?>
    	<li><a href="<?php the_permalink(); ?>"><?php $title = get_the_title(); echo shrink_text($title,27) ?></a></li>
    	<?php } ?>
    	<?php endwhile; ?>
    	</ul>
    Any suggestions greatly appreciated.

    Thanks,
    Karl

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    PHP Code:
    echo '<li><a href="'.the_permalink().'">'.$title.'</a></li>'
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •