Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Plugins & Atahualpa »

How do I include shortcode in a php file?


  #1  
Old Aug 17, 2011, 02:45 PM
scombridae1969
 
17 posts · Jul 2010
Hello Everyone...
I am currently using Atahualpa 3.6.7 on Wordpress 3.2.1. I guess this really isn't specifically an Atahualpa question but I am hoping someone can help me here.

I am using a plugin called "Jquery collapse-o-matic" and I want to include some of the shortcode functionality in another plugin (a custom widget tool). The widget I want to modify allows for excerpts from a post to be included in a list of posts. I want to be able to collapse that excerpt within the widget. I apologize if it sounds like I have no clue because I really don't. What I have tried is adding an "echo do_shortcode" function in the php for that widget but it doesn't seem to do anything. It is as follows:

elseif ( 'the_excerpt' == $instance['entry_content'] ) {
echo '<div class="entry-summary">';
echo do_shortcode('[expand title="More" swaptitle="Minimize"]');
the_excerpt();
echo do_shortcode('[/expand]');
echo '</div>';
}

The "expand title..." and "/expand" are proper shortcodes for the plugin I am using (collapse-o-matic).

If this is the wrong place to ask this, please let me know and I will delete this post.
Mike

Last edited by scombridae1969; Aug 17, 2011 at 02:56 PM.
  #2  
Old Aug 17, 2011, 03:41 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
try taking the echo out. the do_shortcode() is a function.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Aug 17, 2011, 05:27 PM
scombridae1969
 
17 posts · Jul 2010
Thanks, Juggledad!
I tried it but that also did not work.

I have been able, using "echo", to get the shortcode functionality to appear. But they appeared before the excerpt and did not apply to the excerpt. The shortcodes for "collapse-o-matic" are bookended. They are typically read:

[expand title="On" swaptitle="Off"]TARGETED TEXT[/expand]

Just in case my original post was confusing (and not intending to be uselessly redundant):
The shortcodes from "collapse-o-matic" work just fine if I use a standard text widget, insert text and bookend the text with the shortcodes. So what I am trying to do here is create the equivalent, via php, of "the_excerpt" being rendered by another plugin with "collapse-o-matic" shortcodes being applied to it. Obviously, when I tried to include the shortcode on the actual excerpt (editing the actual post) all it did was add the literal text to the excerpt when it was rendered in the widget.

FYI, the widget I am trying to modify is "query-posts" which lets me be very specific about what posts appear in the widget and allows me to include respective excerpts. I am attempting to be able to collapse excerpts within the widget. The original section of PHP from "Query-posts" that I am trying to modify reads:

elseif ( 'the_excerpt' == $instance['entry_content'] ) {
echo '<div class="entry-summary">';
the_excerpt();
echo '</div>';
}

Thanks for your help, Juggledad.
Mike
  #4  
Old Aug 17, 2011, 06:31 PM
scombridae1969
 
17 posts · Jul 2010
I guess another way of asking, based on my perusal of the forum associated with the "collapse-o-matic" would be...

Using this line of PHP provided at the forum:
echo do_shortcode('[expand title="Monkeys"]Monkeys are very fast.[/expand]');

What would I need to do so that the "Monkeys are very fast." text is replaced by the function "the_excerpt()".

I hope this isn't too horribly rookie of me to ask this way. I'm starting to take classes to move me from strictly visual design to code but have not tackled PHP yet.

Mike
  #5  
Old Aug 17, 2011, 07:03 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
You would need a function that gets called an processes the text and calls the_excerpt(). In this case the function would be 'expand_func' and it needs to have the php call to 'the_excerpt()'
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where's the page.php file? ISFNpub Page & Category Menu Bars 13 Sep 20, 2011 05:45 PM
PHP include in CSS Inserts sawyerjw Atahualpa 3 Wordpress theme 10 Apr 8, 2011 02:41 PM
In what php file is the td.logoarea? Shan_LSOS Header configuration & styling 4 Jul 2, 2010 05:23 PM
[SOLVED] &lt;?php include ...?&gt; is not working astera Post-Kicker, -Byline & -Footer 8 Sep 21, 2009 12:52 AM


All times are GMT -6. The time now is 02:04 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.