Okay
  Public Ticket #1370375
How to hide default instructions in Recipe post ?
Closed

Comments

  • Bobby started the conversation

    Hello,

    While creating a new recipe post it is showing one instructions field by default. I left as blank, but it is shows 1 with empty area in the front end. Is there any way to hide the instructions if there is nothing in the instruction field ? 

  •  2,057
    Theme replied

    Hi,

    Can you provide a link to your recipe in the frontend please?

    Are you sure in backend you didn't press the plus button?

    Thanks,

    Best regards,

    themeenergy support

  • Bobby replied

    I haven't hosted the site to public domain, currently on my localhost. Attached the images. There is no minus icon or remove icon for attachment in the back end. 

  •  2,057
    Theme replied

    Hi,

    What is the theme version you are using?

    Best regards,

    themeenergy support

  • Bobby replied

    v.1.29.1: on WordPress 4.8.3

  •  2,057
    Theme replied

    Hi,

    In single-recipe.php, you can find these lines:

    $instruction = $instructions_array[$i]['instruction'];
    echo '<li>';
    echo '<div class="text">';
    echo $instruction;
    echo '</div>';
    if ($sc_theme_globals->enable_instruction_images() && isset($instructions_array[$i]['image']) && $instructions_array[$i]['image'] > 0) {
        $image_id = $instructions_array[$i]['image'];
        $image_src = wp_get_attachment_image_src($image_id, 'full');    
        $image_src = $image_src[0];
        echo '<img src="' . $image_src . '" alt="">';
    }
    echo '</li>';
    

    change it to:

    $instruction = $instructions_array[$i]['instruction'];
    if (!empty(trim($instruction))) {
    echo '<li>';
    echo '<div class="text">';
    echo $instruction;
    echo '</div>';
    if ($sc_theme_globals->enable_instruction_images() && isset($instructions_array[$i]['image']) && $instructions_array[$i]['image'] > 0) {
        $image_id = $instructions_array[$i]['image'];
        $image_src = wp_get_attachment_image_src($image_id, 'full');    
        $image_src = $image_src[0];
        echo '<img src="' . $image_src . '" alt="">';
    }
    echo '</li>';
    }

    Best regards,

    themeenergy support

  • Bobby replied

    That fixed the issue thanks..