WordPress Conditional: Only show if current page title is equal to post meta

Posted by Wade D Ouellet on Stack Overflow See other posts from Stack Overflow or by Wade D Ouellet
Published on 2010-05-14T05:49:05Z Indexed on 2010/05/14 5:54 UTC
Read the original article Hit count: 375

Filed under:
|
|
|
|

Hey,

I am calling a bunch of posts under a certain post type in WordPress which works but I am trying to add a conditional that will check first if those post's custom meta field (labeled "disc") is equal to the current post's title.

Here is what I have but this conditional does not seem to work:

<?php
   $pages = get_posts('numberposts=9999&post_type=song&post_status=publish&order=ASC&orderby=date');

   $i = 1;
   foreach( $pages as $page ) {
       $content = $page->post_title;
       if( empty($content) ) continue;

       $content = apply_filters('the_content', $content); ?>

       <?php if(get_post_meta($page->ID, "p30-disc", true)=="the_title()") { ?>

       <tbody class="vevent">

       <?php if ($i%2===0) { ?><tr class="gigpress-row gigpress-alt">

       <?php } else { ?><tr class="gigpress-row"><?php } ?>

       <td><?php echo $page->post_title ?></td>
        <td><?php echo get_post_meta($page->ID, "p30-length", true); ?></td>
        <td><a href="http://itunes.com/<?php echo get_post_meta($page->ID, "p30-itunes-song", true); ?>">BUY</a></td>

        </tr>

        <tr class="gigpress-info">

        <td colspan="3"><?php echo $page->post_content ?></td>

        </tr>

        </tbody>    

<?php $i++;

   } } ?>

When I simply echo "get_post_meta($page->ID, "p30-disc", true)" or "the_title()" it spits out their proper values, which are equal, so obviously something is just wrong with that conditional.

Thanks,

Wade

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about conditional