views:

42

answers:

2

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/&lt;?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

+1  A: 

It looks like you're "quoting" the title function - essentially, turning it into a string, when you should just be calling it.

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

that should work?

Auston
Hey, sorry I didn't respond earlier but I was away for the weekend.Unfortunately this just spit out the value of the title. I had tried this at one point and was also surprised it didn't work.
Wade D Ouellet
A: 

Turned out there is a function called get_the_title() that is used for this sort of thing. Worked perfectly.

Wade D Ouellet