SQL / Wordpress help needed!!

Discussion in 'Programming' started by podda999, Nov 1, 2009.

  1. #1
    Ok, i have a lot of content on my site which uses a thumbnail image with the default custom field value of 'http://www.animunch.com/1.png' because i implimented the default value after i had lots of post already the ones i already have display a blank image,

    I need a way of updating all of these custom fields in the posts from blank contain the link to the image. I have dried the worpdress plugin mass custom field manager but had no luck with that.

    Im not too good with SQl either but i belive there is a way to use an update query to add the link to the image meta_key field. But weather or not this is in the SQL because the field has not been written to yet is another problem.

    If i can bulk edit the posts somehow this will work, as when you edit the post the defalt value appears in the box, but i would have to do this one by one. And when i use the bulk edit post feature it does not give you the iption of adding a custom value.

    Any help would be great.

    i got this far qith the sql but its just guess work and wont work because the fields dont yet excist within the table.

     
    podda999, Nov 1, 2009 IP
  2. iCode

    iCode Peon

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would do this other way, by code not in the database:

    <?php if (get_post_meta($post->ID, thumbnail)) { ?>

    <img src="<?php echo get_post_meta($post->ID, thumbnail, true); ?>" alt="<?php _e("post thumbnail"); ?>" />

    <?php } else { ?>

    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/def-thumb.gif" alt="<?php _e("post thumbnail"); ?>" />

    <?php } ?>
     
    iCode, Nov 15, 2009 IP