WordPress.org

Support

Support » How-To and Troubleshooting » shortcode in custom field

shortcode in custom field

  • can someone help me parse this shortcode [wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:end] into custom field ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Are you storing the shortcode string you showed in the custom field? Are you already retrieving the custom field?

    If the answer to both is ‘yes’, then you can use code like the following (assuming the custom field is ‘cart-info’):

    $cart_info = get_post_meta($post->ID, 'cart-info', true);
    echo do_shortcode($cart_info);

    well it”s like this

    above the loop i”ve put this
    <?php $price = get_post_meta( $post->ID, ‘price’, true ); ?>

    and i want to display the add to cart button i have this
    <?php echo print_wp_cart_button_for_product($name, $price); ?>

    it”s not working right

    the add to cart button apear on every post, when u press it it add product in cart with no name and no price
    when i sdd key=price and value= 25 it add to cart same noname and noprice product 🙁

    above the loop i”ve put this
    <?php $price = get_post_meta( $post->ID, ‘price’, true ); ?>

    Is the post ID available above the loop?

    i have no idea 🙂

    You might need to hire someone to help with this. You can post a free job request on jobs.wordpress.net.

    this is how u do it

    <?php $price = get_post_meta( $post->ID, 'price', true ); ?>
    <?php $name = get_the_title(); ?> <?php echo print_wp_cart_button_for_product($name, $price); ?>

    that code display the add to cart button

    Price: <?php echo get_post_meta($post->ID, 'price', true); ?> $
    and that”s for the price to be displayed

    have fun

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘shortcode in custom field’ is closed to new replies.