WordPress.org

Ready to get started?Download WordPress

Forums

Testimonials by Aihrus
[resolved] Writing PHP to display Rotating Widget in a template (6 posts)

  1. aaaronscat
    Member
    Posted 1 year ago #

    I am attempting to write some PHP to display the rotating widget from my custom template. I can get the list to show up but not the rotating widget.

    This is the code I am using to display the list:

    <?php
    $args = array(
    'limit' => 1,
    'random' => true,
    );
    echo testimonialswidget_list_shortcode( $args );
    ?>

    What code do I use to display the rotating widget instead? The code you have on your FAQ #1 is not working for me.

    Thanks!

    Great plugin!

    http://wordpress.org/extend/plugins/testimonials-widget/

  2. Michael Cannon
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you for the compliment.

    First off, bad copy and paste. testimonialswidget_list_shortcode vs. testimonialswidget_widget.

    Second, just use <?php echo testimonialswidget_widget(); ?>.

    limit=1 means to only pull one testimonial. Therefore, how can you rotate if there's only one?

  3. aaaronscat
    Member
    Posted 1 year ago #

    Hi Michael,

    It's really great to get a reply from the actual plugin author so thanks a bunch for writing back.

    The only code that doesn't give me an error message or break the entire site is the one I posted above. This one:

    <?php
    $args = array(
    'limit' => 1,
    'random' => true,
    );
    echo testimonialswidget_list_shortcode( $args );
    ?>

    I tried all of these and none of them worked:

    testimonialswidget_widget
    testimonialswidget_widget_shortcode
    testimonialswidget_list

    All of these functions gave me an error message on the page saying that they are undefined. Do I need to first define them somewhere?

    I tried putting <?php echo testimonialswidget_widget(); ?> in my functions.php like you suggest in your FAQ but this broke the whole site.

    Aaron

  4. Michael Cannon
    Member
    Plugin Author

    Posted 1 year ago #

    Is Testimonials Widget plugin activated?

    Please double-check and then if the <?php echo testimonialswidget_widget(); ?> code breaks again, copy and paste the error message here.

  5. aaaronscat
    Member
    Posted 1 year ago #

    Yes, the plugin is activated. That would be the easiest solution I suppose.

    Sorry to be dense but should I put <?php echo testimonialswidget_widget(); ?> into my functions file or use it in my template?

    When I put <?php echo testimonialswidget_widget(); ?> into my homepage template I get this error message on the page itself:

    Fatal error: Call to undefined function testimonialswidget_widget() in /home/content/14/5985714/html/subdomains/karen/wp-content/themes/ksquared/tmp-home.php on line 43

    When I put <?php echo testimonialswidget_widget(); ?> into my functions.php the whole site is broken.

    Aaron

  6. Michael Cannon
    Member
    Plugin Author

    Posted 1 year ago #

    Aaron,

    You can put the <?php echo testimonialswidget_widget(); ?> code into the template file directly, where you want Testimonials Widget to display.

    It sounds like your theme is loading up before the plugins. I'm not sure if this is normal behavior or not. Therefore, you might try to fuller code before to include your one-off.

    <?php
    include_once( WP_PLUGIN_DIR . '/testimonials-widget/testimonials-widget.php' );
    echo testimonialswidget_widget();
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.