• i am working on an existing theme i have made, and im trying to clean it up a bit code wise, by adding action hooks etc.

    most are fine, but i am trying to add a feature to my post options where you can input image/video/download locations and they will display in a table under the content.

    i have another hook which works fine in this location, but this ones being a bit awkward.

    it will display the table, but the table is empty, could someone point out where i am going wrong.

    <?php
    function post_thumbs() { ?>
    <table cellspacing="0" cellpadding="10px" border="0" width="100%">
    <tr>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_1', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_1', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_1', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_2', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_2', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_2', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_3', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_3', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_3', true); ?>" /></a><?php } else { ?><?php } ?></td>
    </tr>
    <tr>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_4', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_4', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_4', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_5', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_5', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_5', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_6', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_6', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_6', true); ?>" /></a><?php } else { ?><?php } ?></td>
    </tr>
    <tr>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_7', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_7', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_7', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_8', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_8', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_8', true); ?>" /></a><?php } else { ?><?php } ?></td>
    <td width="33%"><?php if(get_post_meta($post->ID, 'thumbnail_9', true)) { ?><a href="<?php echo get_post_meta($post->ID, 'thumbnail_9', true); ?>" rel="shadowbox[<?php echo $post->ID ?>]"><img class="pthumb" src="<?php echo get_post_meta($post->ID, 'thumbnail_9', true); ?>" /></a><?php } else { ?><?php } ?></td>
    </tr>
    </table>
    <center>
    <?php echo get_post_meta($post->ID, 'video_embed_1', true); ?>
    <?php echo get_post_meta($post->ID, 'video_embed_2', true); ?>
    <?php echo get_post_meta($post->ID, 'video_embed_3', true); ?>
    </center>
    <?php if(get_post_meta($post->ID, 'file', true)) { ?>
    <a href="<?php echo get_post_meta($post->ID, 'file', true); ?>"><h4 class="file">Download File</h4></a>
    <?php } else { ?>
    <?php } ?>
    <?php } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • what does echo $post->ID; output in your function?

    if it is empty, maybe global $post; is missing at the start of the function.

    Thread Starter ext103

    (@ext103)

    i dont know, how would i check?

    this code worked fine while in the page and post templates.

    im trying to move it to a function to clean up the code.

    maybe you are onto something with the global $post thing.

    how would i implement it into this function?

    <?php
    function post_thumbs() {
    global $post; ?>
    <table cellspacing......
    Thread Starter ext103

    (@ext103)

    thanks, i figured it out before checking back to say thanks.

    so thank you, all is good.

    ps. and thanks for not digging at me for using tables 🙁

    wanna get it working and then style it with a list i think.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘help with action hooks’ is closed to new replies.