• Resolved mgp271gmailcom

    (@mgp271gmailcom)


    How would you set a default text field value for a Meta Box? Below is what I have for a Meta Box Text Field. Although, having trouble pushing a default value without having to create a select box.

    <?php
    $this->text(‘main_top_padding’,
    __(‘Page Content Top Padding’, ‘Theme’),
    __(‘In pixels ex: 20px. Leave empty for default value.’, ‘Theme’)
    );
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mgp271gmailcom

    (@mgp271gmailcom)

    Resolved: I wrote a new condition in the frontend stating if value is set, set the value, if value is not set, set the value as 100px.

    <?php if(get_post_meta($c_pageID, ‘pyre_main_top_padding’, true)): ?>
    padding-top:<?php echo get_post_meta($c_pageID, ‘pyre_main_top_padding’, true); ?>;
    <?php else: ?>
    padding-top:60px;
    <?php endif; ?>

    Thread Starter mgp271gmailcom

    (@mgp271gmailcom)

    excuse me 60px

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How would you set a default text field value for a Meta Box?’ is closed to new replies.