Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using WP as a CMS. I've got multiple pages that share the same header.

group 1 has header 1. group 2 has header 2. etc.

I've looked at these two plugins for a quick way to insert a combination of html and shortcodes. http://wordpress.org/extend/plugins/wp-include-file/ http://wordpress.org/extend/plugins/post-snippets/

Both solutions are neat, but they do not process the short codes.

Example:

<div id="bugs2">

[caption id="attachment_214" align="alignnone" width="75" caption="Pack Rat"]<a href="pack-rat/"><img class="size-full wp-image-214" title="ID Pack Rat" src="http://xyz.com/epm/wp-content/uploads/2011/01/ID-Pack-Rat-e1295503174487.jpg" alt="" width="75" height="75" /></a>[/caption]

[caption id="attachment_218" align="alignnone" width="75" caption="Pocket Gopher"]<a href="pocket-gopher/"><img class="size-full wp-image-218" title="ID Pocket Gopher" src="http://xyz.com/epm/wp-content/uploads/2011/01/ID-Pocket-Gopher-e1295503138319.jpg" alt="" width="75" height="75" /></a>[/caption]

</div>

Does anyone know of an alternative way to embed or include this code from an external file (in an include folder on the server) and have the shortcodes processed?

Thanks!

share|improve this question
add comment

3 Answers 3

I have done this before with wp-include-file you need to edit the file called wp-include-file.php in the plugin`s directory look at line 144 and replace:

return $content;

with

return do_shortcode($content);

that`s it.

hope this helps.

share|improve this answer
add comment

Didn't test it but rather than editing plugin file it might be more convenient to wrap its call in your own function and re-register shortcode. Something like this:

function wp_include_file_with_shortcode( $atts ) {

    return do_shortcode( wp_include_file( $atts ) );
}

remove_shortcode( 'include' );
add_shortcode( 'include', 'wp_include_file_with_shortcodes' );
share|improve this answer
    
that would be a smarter approach, I agree 100%. –  Bainternet Jan 24 '11 at 8:57
add comment

My plugin get-post should handle this. It allows you to include posts in other posts/pages and will go ahead and process plugins during this inclusion. It should allow for a little bit of recursion as well :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.