skip to Main Content

Why this is show me nothing??
I’m totally lost =(

<?php function calc_shortcode(){ ?>
<div>
    <form>
        <h3>Price High</h3>
        <input name="priceHigh" type="text" />
        <h3>Price Low</h3>
        <input name="priceLow" type="text" />
        <h3>Price Up</h3>
        <input name="priceUp" type="text" />
        <h3>Price Down</h3>
        <input name="priceDown" type="text" /></br>
        <input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
    </form>
</div>
<?php 
} 

add_shortcode('calc_pat', 'calc_shortcode'); 

Thanks for helping guys!

4

Answers


  1. The php labels are wrongly placed there, try doing this:

    <?php
    function calc_shortcode(){ 
    <div>
        <form>
            <h3>Price High</h3>
            <input name="priceHigh" type="text" />
            <h3>Price Low</h3>
            <input name="priceLow" type="text" />
            <h3>Price Up</h3>
            <input name="priceUp" type="text" />
            <h3>Price Down</h3>
            <input name="priceDown" type="text" /></br>
            <input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
        </form>
    </div>
     
    } 
    
    add_shortcode('calc_pat', 'calc_shortcode');
    ?>
    

    Check if that works

    Login or Signup to reply.
  2. Please give try to below code, it should work:

    function calc_shortcode(){ 
    echo '<div>
        <form>
            <h3>Price High</h3>
            <input name="priceHigh" type="text" />
            <h3>Price Low</h3>
            <input name="priceLow" type="text" />
            <h3>Price Up</h3>
            <input name="priceUp" type="text" />
            <h3>Price Down</h3>
            <input name="priceDown" type="text" /></br>
            <input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
        </form>
    </div>';
    } 
    
    add_shortcode('calc_pat', 'calc_shortcode');
    

    you can also add ob_start(); and ob_get_clean();

    Login or Signup to reply.
  3. Try below code :

    <?php function calc_shortcode()
    {
        ob_start();
    ?>
        <div>
            <form>
                <h3>Price High</h3>
                <input name="priceHigh" type="text" />
                <h3>Price Low</h3>
                <input name="priceLow" type="text" />
                <h3>Price Up</h3>
                <input name="priceUp" type="text" />
                <h3>Price Down</h3>
                <input name="priceDown" type="text" /></br>
                <input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
            </form>
        </div>
    <?php
        echo ob_get_clean();
        die();
    }
    
    add_shortcode('calc_pat', 'calc_shortcode');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search