WordPress.org

Ready to get started?Download WordPress

Forums

Collapse-O-Matic
[resolved] Using in template (10 posts)

  1. richleppard2
    Member
    Posted 1 year ago #

    Hi, great plugin, I worked out how to use it in template:

    <?php
    
    echo do_shortcode('[expand title="<h3>USA</h3>"]
    
    html content
    
    [/expand]');?>

    However I'd like to know how to use a php include where the html would be ie: <?php include(/file.php);?>

    My php is no good, can someone suggest something. The included file would also include php as I'm using the advanced custom fields plugin.

    Thanks

    http://wordpress.org/extend/plugins/jquery-collapse-o-matic/

  2. Baden
    Member
    Plugin Author

    Posted 1 year ago #

    Explain more about what you mean by:

    php include where the html would be
    Are you wanting to include content from a WordPress post, or load up one of your theme's templates? What does file.php do?

  3. richleppard2
    Member
    Posted 1 year ago #

    In literal terms: where the above snippet says 'html content' I would want the equivalent of <?php include(includes/list.php);?>. The file this refers to would be an unordered list in html but each

  4. tag would contain <?php get_field('name');?>.

    My problem is I have no experience of inserting php within php. In the above example the expand tags are opened and closed but the space between them only seems to allow html.

    Thanks for your response.

  • richleppard2
    Member
    Posted 1 year ago #

    Reposting as that may not be viewable.

    In literal terms: where the above snippet says 'html content' I would want the equivalent of <?php include(includes/list.php);?> The file this refers to would be an unordered list in html but each would contain <?php get_field('name');?>

    My problem is I have no experience of inserting php within php. In the above example the expand tags are opened and closed but the space between them only seems to allow html.

    Thanks for your response.

  • Baden
    Member
    Plugin Author

    Posted 1 year ago #

    Why are you using an external .php file for your content? Is it a template, or does the php file only contain static content? Do you have anyone that is more familiar with php to help you out? I think there is a much cleaner, simpler way to achieve what you are trying to accomplish.

  • richleppard2
    Member
    Posted 1 year ago #

    In fairness the external php file is just to keep tidy. However the content I want expanded needs to be a php handle so that I can link it to the backend of wordpress for the client to update. I'll try stack overflow. It's a bit of a unique problem because the shortcode is specific to WordPress and the plugin and so I'm not sure how it effects the syntax of php.

    Thanks for your help.

  • Baden
    Member
    Plugin Author

    Posted 1 year ago #

    Let us know how you get it solved! So you do not give the client access to WordPress, just a php file that they will update/upload via FTP?!

  • richleppard2
    Member
    Posted 1 year ago #

    I use Advanced Custom Fields plugin. I create a custom field for them and then put the php get_field into the template. I find it works a charm but Ive never had to include such a call into another piece of php.

  • Baden
    Member
    Plugin Author

    Posted 1 year ago #

    Not sure if this will help, but you could try something like:

    <?php
    $field_name = get_field('name');
    include('includes/'.$field_name.'.php');
    ?>

    But this is beyond the scope of our plugin. Best of luck!

  • richleppard2
    Member
    Posted 1 year ago #

    Thanks (for the help and the plugin of course)

  • Topic Closed

    This topic has been closed to new replies.

    About this Plugin

    About this Topic

    Tags