Support » Themes and Templates » If Post Meta Equals Current Title Conditional

  • Hi,

    I am trying to write a conditional to only show results if their certain “disc” post meta value is equal to the current post or page’s title.

    Here is my loop with the conditional I have going, which is currently just spitting out the post title for each result in the loop.

    <?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); ?>" class="blank">BUY</a></td>
    
    		</tr>
    
            <?php if ($page->post_content) { ?>
    
            <tr class="gigpress-info">
    
            <td colspan="3"><?php echo $page->post_content ?></td>
    
            </tr>
    
            <?php } ?>
    
            </tbody>	
    
    <?php $i++;
    
       } } ?>

    Thanks,
    Wade

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘If Post Meta Equals Current Title Conditional’ is closed to new replies.