WordPress.org

Support

Support » Plugins and Hacks » How do I display dynamic text in echoes?

How do I display dynamic text in echoes?

  • Could anyone help me fix this so that my wp tags work in this piece of code… thanks heaps!

    <?php $typography = of_get_option('example_typography2');
                if ($typography) {
                    echo '<span style="font-family: ' . $typography['face']. '; font-size:'.$typography['size'] . '; font-style: ' . $typography['style'] . '; color:'.$typography['color'].';">
    				<a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a>
    				</span>';
                } else {
                    echo "no entry";
                } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi!

    Change your 4th line to this:

    <a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a>

    You could also use get_bloginfo('siteurl'), but it is flagged as deprecated in the correspondingget_bloginfo` Codex article.

    Cheers!

    you can either switch back and forth from php and echo to html and ‘normal’ php;
    example:

    <?php $typography = of_get_option('example_typography2');
                if ($typography) {
                    echo '<span style="font-family: ' . $typography['face']. '; font-size:'.$typography['size'] . '; font-style: ' . $typography['style'] . '; color:'.$typography['color'].';">#'; ?>
    				<a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a>
    				<?php echo '</span>';
                } else {
                    echo "no entry";
                } ?>

    or use proper string concatenation with using those WordPress functions which return the output; such as get_bloginfo() or home_url();
    example:

    <?php $typography = of_get_option('example_typography2');
                if ($typography) {
                    echo '<span style="font-family: ' . $typography['face']. '; font-size:'.$typography['size'] . '; font-style: ' . $typography['style'] . '; color:'.$typography['color'].';">
    				<a href="'. home_url() . '/">'. get_bloginfo('name') .'</a>
    				</span>';
                } else {
                    echo "no entry";
                } ?>

    http://php.net/manual/en/language.operators.string.php

    Thanks to both…. I always prefer html/php so thanks so much for that alchymyth!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I display dynamic text in echoes?’ is closed to new replies.
Skip to toolbar