WordPress.org

Ready to get started?Download WordPress

Forums

how to get all the value of special meta_key (2 posts)

  1. maojiemng
    Member
    Posted 5 years ago #

    the same as the title.
    I wirte a function named get_meta_value.But I Can't get the key_value of the special meta_key.In fact there should be 2 value.

    pluging file:

    function get_meta_value( $meta_key) {
    	global $wpdb;
    	$meta_value=$wpdb->query('Select meta_value FROM $wpdb->postmeta WHERE meta_key = '.$meta_key);
    	return $meta_value;
    }

    index.php file

    <?php
    $thumbnail=get_meta_value('portfolio_img');
    for($i=0;$i<count($thumbnail);$i++) {
    ?>
    <img src="<?php echo $thumbnail[1];?>"/>
    <?php }?>

    is there any problem?anybudy can help me?

  2. MichaelH
    Member
    Posted 5 years ago #

    Using_Custom_Fields has information and get_post_custom_values should work for you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.