WordPress Conditional: Only show if current page title is equal to post meta
- by Wade D Ouellet
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