WordPress.org

Ready to get started?Download WordPress

Forums

Squelch Tabs and Accordions Shortcodes
[resolved] Embed Accordion in PHP Page (2 posts)

  1. Joe Streno
    Member
    Posted 10 months ago #

    I'm trying to embed an accordion into a WordPress PHP file, so when it's called as a page in a browser, it will show the accordion and its contents. Below is the code I use. When the page draws the accordion code appears as text in the page & not an accordion. I've also tried wrapping the short codes div in a <?php Echo ?> but that doesn't work either. Any ideas?

    Thanks ... Joe

    <?php
    /*
    Template Name: Photos: Pets
    */
    ?>
    
    <?php get_header() ?>
    
    	<div class="photo-page-title">Photos: Pets</div>
    <div class="photo-accordian">
    [accordions title="" disabled="false" active="0" autoheight="false" collapsible="true"]
    
    [accordion title="Pane 0"]
    Accordion pane 0 content[/accordion]
    
    [accordion title="Pane 1"]
    Accordion pane 1 content
    [/accordion]
    
    [accordion title="Pane 2"]
    Accordion pane 2 content
    [/accordion]
    
    [/accordions]
    </div>
    
    <?php get_footer() ?>

    http://wordpress.org/plugins/squelch-tabs-and-accordions-shortcodes/

  2. Matt Lowe
    Member
    Plugin Author

    Posted 10 months ago #

    Hi Joe,

    You need to use do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode

    Something like this should work:

    <?php get_header() ?>
    
    	<div class="photo-page-title">Photos: Pets</div>
    <div class="photo-accordian">
    <?php
    $acc = <<EOF
    [accordions title="" disabled="false" active="0" autoheight="false" collapsible="true"]
    
    [accordion title="Pane 0"]
    Accordion pane 0 content[/accordion]
    
    [accordion title="Pane 1"]
    Accordion pane 1 content
    [/accordion]
    
    [accordion title="Pane 2"]
    Accordion pane 2 content
    [/accordion]
    
    [/accordions]
    EOF;
    echo do_shortcode($acc);
    ?>
    </div>
    
    <?php get_footer() ?>

    See also: http://wordpress.org/support/topic/best-way-to-insert-php-into-tabs?replies=6

    Thanks,
    Matt

Reply

You must log in to post.

About this Plugin

About this Topic

Tags