Putting PHP code inside echo ” WordPress

This is in my theme-function.php. I’m printing this to the index.php. I am trying to make it dynamic,(changing it on my backend) but if I paste the 2nd code below the browser displays Server error 500.

1st code original code:

Read More
  <p class="welcome-block-text">Juan Aquino<br>

2nd code: how to make like this

 echo '<div class="row">

 if(get_option($shortname.'_custom_text_url','') != "") { 
        <p class="welcome-block-text">echo get_option($shortname.'_custom_text_url',''); <br>
 } else {
    <p class="welcome-block-text">Juan Aquiano<br>
 }

Related posts

3 comments

  1. Here is the Code Below refer it

    echo '<div class="row">';
    if(get_option($shortname.'_custom_text_url','') != "") { 
    echo '<p class="welcome-block-text'.get_option($shortname.'_custom_text_url','').'<br>';
    } else {
    echo '<p class="welcome-block-text">Juan Aquiano<br>';
    }
    
  2. echo '<div class="row">' . ((get_option($shortname . '_custom_text_url', '') != "") ? '<p class="welcome-block-text">' . get_option($shortname . '_custom_text_url', '') . '<br/>' : '<p class="welcome-block-text">Juan Aquiano<br>');
    

    Don’t forget to close <p> and <div>

  3. More simplified way to achieve this :

    <?php 
    if(get_option($shortname.'_custom_text_url','') != ""){
        $p_text = get_option($shortname.'_custom_text_url','').'<br> ';
    } else{
        $p_text = 'Juan Aquiano<br> ';
    }
    echo '<div class="row"><p class="welcome-block-text">'.$p_text.'</p></div>';
    ?>
    

Comments are closed.