LostInQuery
LostInQuery

Reputation: 519

WordPress the_permalink() outputting nothing

I can outputting all of my posts in a custom post type called Featured Projects. The outputting of the psots work fine, as do the custom post values from the custom meta box. What doesn't output is the_permalink() and the_title(). They are just blank.

If you have any clue what I screwed up or what I can check, I would appreciate it!

<ul id="projects-nav">
  <?php query_posts('post_type=featured-projects&order=ASC&orderby=menu_order&posts_per_page=-1'); ?>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <?php $agency = get_post_custom_values('agency'); ?>
  <?php $production = get_post_custom_values('production'); ?>
  <?php $post = get_post_custom_values('post'); ?>
  <?php $video_url = get_post_custom_values('video_url_1'); ?>
  <?php $thumb_url = get_post_custom_values('thumb_url_1'); ?>
  <li>
  <a href="<?php the_permalink(); ?>"><img alt="<?php the_title(); ?>" src="<?php echo $thumb_url[0]; ?>" width="185" height="113"></a>
  <h4><?php the_title(''); ?></h4>
  <?php the_content(""); ?>
  <?php if($agency[0] != '') { ?><p>Agency: <?php echo $agency[0]; ?></p><?php } ?>
  <?php if($production[0] != '') { ?><p>Production: <?php echo $production[0]; ?></p><?php } ?>
  <?php if($post[0] != '') { ?><p>Post: <?php echo $post[0]; ?></p><?php } ?>
 </li>
 <?php endwhile; endif; ?>
</ul>

Upvotes: 1

Views: 646

Answers (3)

LostInQuery
LostInQuery

Reputation: 519

After a lot of headaches and thrashing around and trying lots of different things. For some reason changing the placement of the variables seemed to make it all work. The final code ended up being

<ul id="projects-nav">
  <?php query_posts('post_type=projects&order=ASC&orderby=menu_order'); ?>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <?php $thumb_url = get_post_custom_values('thumb_url_1'); ?>
  <li> 
        <a href="<?php the_permalink(); ?>"><img alt="<?php the_title(''); ?>" src="<?php echo $thumb_url[0]; ?>" width="185" height="113"></a>
        <h4><?php the_title(''); ?></h4>
        <?php the_content(''); ?>

    <?php $agency = get_post_custom_values('agency'); ?>
    <?php $production = get_post_custom_values('production'); ?>
    <?php $post = get_post_custom_values('post'); ?>
        <?php if($agency[0] != '') { ?><p>Agency: <?php echo $agency[0]; ?></p><?php } ?>
        <?php if($production[0] != '') { ?><p>Production: <?php echo $production[0]; ?></p><?php } ?>
        <?php if($post[0] != '') { ?><p>Post: <?php echo $post[0]; ?></p><?php } ?>
    </li>
    <?php endwhile; endif; ?>
</ul>

Thanks to everyone else who tried to help!!

Upvotes: 1

andrewk
andrewk

Reputation: 3871

i think you should first try to get posts from $agency only then if it works try $production.

i don't think it know the_title() of what custom post type to get. try the whole thing with 1 custom post type first then add. my $0.02

Upvotes: 0

Elliott Bowles
Elliott Bowles

Reputation: 398

For the permalink, you can use the following alternative:

Also did you try removing the quotes inside the ? That could be messing with it.

Upvotes: 0

Related Questions