• How can I output in bold the number of this function:

    <div class="prezzo"><form><input type="button" class="prezzo" value="da <?php echo get_post_meta( get_the_ID(), "function_prezzo_minimo", true ); ?> euro/notte"> </form></div>
    

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello there,

    To set the output bold, you can wrap the return value with “<b></b>” syntax before return it. Something like this.

    $val = "<b> this is a return value</b>";
    return $val;
    Thread Starter sacconi

    (@sacconi)

    And in my case I should write $val just nearby the function in bold like this

    ,$val "function_prezzo_minimo",

    ?

    Moderator bcworkz

    (@bcworkz)

    Wrap the <input> tag: <b><input ... /></b>

    FWIW, I think the <b> tag is discouraged and <strong> is preferred.

    Thread Starter sacconi

    (@sacconi)

    Only the number should be STRONG, the other words on the button have to stay regular

    Maybe you can try add <b> after echo. Something like this.

    <div class="prezzo"><form><input type="button" class="prezzo" value="da <?php echo <b> get_post_meta( get_the_ID(), "function_prezzo_minimo", true ) </b>; ?> euro/notte"> </form></div>

    I hope this helps.

    Thread Starter sacconi

    (@sacconi)

    It breaks the site ??

    Sorry, @sacconi. My Bad. I forgot to add double quotes. The pattern is like this:

    "<b>" . $value . "</b>"

    So, the right code should be like this:

    <div class="prezzo"><form><input type="button" class="prezzo" value="da <?php echo "<b>" . get_post_meta( get_the_ID(), "function_prezzo_minimo", true ) . "</b>"; ?> euro/notte"> </form></div>

    I hope it helps.

    Thread Starter sacconi

    (@sacconi)

    sorry, not working: https://ibb.co/0r5FnSM

    For the previous answer, try to change double quote “<b>” “</b>” with single quote one. Since it’s already wrapped with double quote. Like this:

    <div class="prezzo"><form><input type="button" class="prezzo" value="da <?php echo '<b>' . get_post_meta( get_the_ID(), "function_prezzo_minimo", true )  .  '</b>'; ?> euro/notte"> </form></div>

    Or, wrap it in a span with a class assigned to it

    <div class="prezzo">
    <form>
    <input type="button" class="prezzo" value="da 
    <?php 
    $test = get_post_meta( get_the_ID(), "function_prezzo_minimo", true );
     echo "<span style='font-weight:700;'>$test</span>";
     euro/notte">
    </form>
    </div>
    Thread Starter sacconi

    (@sacconi)

    sorry, nothing works

    I don’t think I have any other idea. The last thing to should try maybe change input type to button. Instead of <input type=”button”>, maybe you should utilize <button> instead. For more robust functionality.

    With <button>, you just need something like this to have partially bold text.

    <button type="submit">This is <b>Bold</b></button>

    So, maybe you can try something like this instead.

    <div class="prezzo"><form>
    <?php 
    $test = get_post_meta( get_the_ID(), "function_prezzo_minimo", true ); 
    <button type="submit" class="prezzo">
    da <b>$test</b> euro/notte
    </button>
    ?>
    </form></div>

    If this doesn’t work either. I’m sorry. I can’t help anymore.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘output of a function in BOLD’ is closed to new replies.