• Resolved callender

    (@jimcallender)


    Hi there,

    I want to display the ‘recent comments’ in wp-carousel.

    <ol class="commentlist"><?php wp_list_comments(array('style' => 'ol')); ?></ol>

    The ‘costumized content’ widget does not execute this php.

    Any ideas for executing php code within the WP-Carousel greatly appreciated!

    Regards,

    Jim C.

Viewing 1 replies (of 1 total)
  • Thread Starter callender

    (@jimcallender)

    Hello,

    I had a similar problem with posts. I wanted to show the number of published posts in a post and I wanted this number to be updated every time I publish a new post. The solution was to use a keyword (something like, for instance, [LAST_COMMENTS]) and replace that keyword later with filters and actions.

    But with WP Carousel you have it easier. First, select a keyword, for instance, [LAST_COMMENTS]. Then modify your WP Carousel’s theme and replace this line:

    <?php foreach ($items as $i_id => $item): ?>

    With these three lines:

    <?php foreach ($items as $i_id => $item): ?>
    <?php $replacement = '<ol class="commentlist">'.wp_list_comments(array('style' => 'ol')).'</ol>'; ?>
    <?php str_replace('[LAST_COMMENTS]', $replacement, $item['DESC']); ?>

    The only problem you will get is that wp_list_comments prints by default the comments (instead of returning them), so you need to set a callback function to return the content in order to allow the variable $replacement to store the comments. You have more info about this in the codex.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: WP Carousel] – execute PHP code in widget?’ is closed to new replies.