WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Shortcode issue (2 posts)

  1. stuart_edwards5
    Member
    Posted 2 years ago #

    Hi there, I'm not sure if I've posted this problem in the correct section of the forum. I hope someone can help either way.

    Am I Nearly There Yet?

    I'm attempting to add some shortcode to the bottom of my posts. I've so far had sucsess adding the below code to my function.php file.

    add_shortcode('stuart', 'stuartBotPost');
    
    function stuartBotPost() {
        return '
            <div class="whoweare">
                	<img src="http://www.gravatar.com/avatar/b80039d3cf7dbfdf4d25130b06c08802.png" alt="mini Stu"/>
    		<h4>About the author</h4>
                	<p>Stuart Edwards is the co-head Honcho at Am I Nearly There Yet?. He likes travelling, single malt whiskey, web design and all things techie. Not necessarily in that order. Read more about Stuart <a href="http://aminearlythereyet.com/authors">here</a>.</p>
            </div>';
    }
    
    add_filter('widget_text', 'do_shortcode');

    That works fine. Now when I add another shortcode, it results in failure and the page fails to load.

    add_shortcode('eloise', 'eloiseBotPost');
    
    function eloiseBotPost() {
        return '
            <div class="whoweare">
                	<img src="http://www.gravatar.com/avatar/e44c4f6b5e6d25ff3ae8ef328c014099.png" alt="Eloise mini"/>
    		<h4>About the author</h4>
                	<p><p>Eloise Rodgers is the co-founder of Am I Nearly There Yet?. When not seeking out the best local vegan cuisine, she's travelling the globe looking for it. She likes vintage things and making beautiful <a href="http://thehatqueen.com" target="_blank">hats and head pieces</a>.Read more about Eloise <a href="http://aminearlythereyet.com/authors">here</a>.</p>
           </div>';
    }

    Now, if I delete the bulk of the content within the <p> tags, it works. I've experimented a little bit. If I leave the bulk of the content the same as the [stuart] shortcode, it works fine! What's that about?!

    add_shortcode('eloise', 'eloiseBotPost');
    
    function eloiseBotPost() {
        return '
            <div class="whoweare">
                	<img src="http://www.gravatar.com/avatar/e44c4f6b5e6d25ff3ae8ef328c014099.png" alt="Eloise mini"/>
    		<h4>About the author</h4>
                	<p>Eloise Rodgers is the co-head Honcho at Am I Nearly There Yet?. He likes travelling, single malt whiskey, web design and all things techie. Not necessarily in that order. Read more about Stuart <a href="http://aminearlythereyet.com/authors">here</a>.</p>
            </div>';
    }

    Is there a maximum character allowance within the shortcode that causes this to fail?

    Does the shortcode formatting have to be exactly the same as the shortcode above it?

    I'm not a PHP whizz unfortunatley. I just can't figure this out, seems totally bizzare!

  2. stuart_edwards5
    Member
    Posted 2 years ago #

    Found the problem.

    The ' in my HTML was spoiling the day.

    Back to HTML school for me!

Topic Closed

This topic has been closed to new replies.

About this Topic