Answers for "wordpress get_post_meta"

PHP
1

add post meta wordpress

<?php

$post_id = 1;
$meta_key = '_test';
$meta_value = 'this is a test';
$unique = true;

add_post_meta( $post_id, $meta_key, $meta_value, $unique );
Posted by: Guest on June-03-2020
1

wp get meta field value

<?php $key_1_value = get_post_meta( get_the_ID(), 'key_1', true ); ?>
Posted by: Guest on June-23-2020
0

wp get meta field value

<?php if ( get_post_meta( get_the_ID(), 'thumb', true ) ) : ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">
        <img class="thumb" src="<?php echo esc_url( get_post_meta( get_the_ID(), 'thumb', true ) ); ?>" alt="<?php the_title_attribute(); ?>" />
    </a>
<?php endif; ?>
Posted by: Guest on June-23-2020
0

meta_value wordpress

$meta_query_args = array(
    'relation' => 'OR', // Optional, defaults to "AND"
    array(
        'key'     => '_my_custom_key',
        'value'   => 'Value I am looking for',
        'compare' => '='
    )
);
$meta_query = new WP_Meta_Query( $meta_query_args );
Posted by: Guest on November-29-2020

Browse Popular Code Answers by Language