Jump to content

Recommended Posts

I'm modifying a Wordpress theme to display a custom post type which is all working fine. However, what I want to do is to have the 'author's bio' box added to each of these automatically.

 

What i've done is created a function in the single-loop.php file of the theme that controls the post output that cycles through the 3 custom fields i've created for those posts and echoes them. This works fine. I'm trying to add the author's bio box that comes with the theme that utilizes shortcodes. Here's the problem. ALL the examples i've seen show a single parameter shortcode. The author's box actually uses 3 different shortcodes for the display. Example:

 

[author] [author_image timthumb='on']http://www.blahblahblah.com/wp-content/themes/trim-child/images/mnr-headshot-300.jpg[/author_image] [author_info]
<h4>BlahBlah - Attorney At Law</h4>
<p>Attorney Blah is an accomplished criminal defense lawyer with over two decades of trial experience in a variety of criminal offenses. Attorney Blah serves clients in the Palm Springs, San Bernardino and Riverside areas.</p>
<p>For Legal Representation <strong>Call 760-333-3333</strong></p>
[/author_info] [/author]

 

The [author] is the main shortcode that starts the box. The [author_image] is self explanatory as well as the [author_info]. In the Wordpress documentation it just says do this:

 

echo do_shortcode('[author]'.Put all your text and content here.'[/author]');

 

So where I'm confused is the syntax in stringing these all together. I've tried variations of this:

 

echo do_shortcode('[author][author_image timthumb='on']'.http://www.blahblahblah.com/wp-content/themes/trim-child/images/mnr-headshot-300.jpg.'[/author_image] [author_info]'.<h4>Blah Blah - Attorney At Law</h4><p>Attorney Blah is an accomplished criminal defense lawyer with over two decades of trial experience in a variety of criminal offenses. Attorney Blah serves clients in the Palm Springs, San Bernardino and Riverside areas.</p><p>For Legal Representation <strong>Call 760-333-3333</strong></p>
'[/author_info][/author]');

 

But that produces T_String syntax errors. I'm trying to figure out how to parse the necessary shortcode parameters along with the main shortcode. Any help is greatly appreciated!

echo do_shortcode('[author][author_image timthumb='on']'.http://www.blahblahblah.com/wp-content/themes/trim-child/images/mnr-headshot-300.jpg.'[/author_image] [author_info]'.<h4>Blah Blah - Attorney At Law</h4><p>Attorney Blah is an accomplished criminal defense lawyer with over two decades of trial experience in a variety of criminal offenses. Attorney Blah serves clients in the Palm Springs, San Bernardino and Riverside areas.</p><p>For Legal Representation <strong>Call 760-333-3333</strong></p>
'[/author_info][/author]');

 

Might make it easier to find the problem. You need to escape your single quotes inside the string. You then need to quote the other strings.

I fixed one pair, but there are others.

 

echo do_shortcode('[author][author_image timthumb=\'on\']'.'http://www.blahblahblah.com/wp-content/themes/trim-child/images/mnr-headshot-300.jpg'.'[/author_image] [author_info]'.<h4>Blah Blah - Attorney At Law</h4><p>Attorney Blah is an accomplished criminal defense lawyer with over two decades of trial experience in a variety of criminal offenses. Attorney Blah serves clients in the Palm Springs, San Bernardino and Riverside areas.</p><p>For Legal Representation <strong>Call 760-333-3333</strong></p>
'[/author_info][/author]');

Worked like a charm! The two things, for anyone else needing this, was escaping those internal quotes AND also using the '.' concatenate properly.  Here's what I wound up with:

 

echo do_shortcode('[author][author_image timthumb=\'on\']'.'http://www.blahblahblah.com/wp-content/themes/trim-child/images/mnr-headshot-300.jpg'.'[/author_image] [author_info]'.'<h4>Blah Blah - Attorney At Law</h4><p>Attorney Blah is an accomplished criminal defense lawyer with over two decades of trial experience in a variety of criminal offenses. Attorney Blah serves clients in the Palm Springs, San Bernardino and Riverside areas.</p><p>For Legal Representation <strong>Call 760-333-3333</strong></p>
'.'[/author_info][/author]');

 

The Wordpress documentation only discussed the concactinating of the actual content and didn't reference anything about the additional shortcode calls nor the parameters of each shortcode.

 

So thanks for the quick fix!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.