WordPress.org

Forums

Math and Custom Fields (2 posts)

  1. skitelluride531
    Member
    Posted 5 years ago #

    I am using the following code to create a variable that references a custom ID:

    <? $prodid = get_post_meta($post->ID, 'product-id', true) ?>

    Later on, I want to use the same custom field, but multiply it by 2. Is this possible with PHP? I am thinking something ike this:

    <?php $prodid*2 ?>

    I know this is far from correct, however, I know it is something simple; I just don't know enough PHP to figure it out!

    Thanks so much!

  2. skitelluride531
    Member
    Posted 5 years ago #

    Solved!

    <?

    $second_number = 2;
    $sum_total = $second_number * $prodid;

    print ($sum_total);

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic