Integration Guide for I Recommend this Plugin

For Site Builders

Shortcode Placement Options

Add recommendation buttons anywhere using shortcodes:

  • Basic usage in posts/pages:
    [irecommendthis]
  • In page builders or text widgets:
    [irecommendthis]
  • In templates with PHP:
    <?php echo do_shortcode('[irecommendthis]'); ?>

Popular Posts Display

Show most recommended posts using shortcodes:

[irecommendthis_top_posts number="5" container="div" show_count="1"]

Advanced usage examples:

  • Custom time period:
    [irecommendthis_top_posts number="3" year="2023" monthnum="6"]

    Shows top 3 posts from June 2023

  • Custom post types:
    [irecommendthis_top_posts post_type="product" number="5"]

    Shows top 5 recommended products (for WooCommerce etc.)

  • Custom HTML structure:
    [irecommendthis_top_posts container="div" wrapper="section" wrapper_class="top-recommendations"]

    Wraps items in divs inside a section with custom class

Query Loop Integration

When using block editor query loops:

  1. Add the “I Recommend This” block inside your post template
  2. Ensure “Use current post in query loops” is checked in block settings
  3. The block will automatically display the correct recommendation count for each post

For Theme Developers

Template Tag Usage

Basic implementation:

<?php
if (function_exists('irecommendthis')) {
    irecommendthis();
}
?>

Advanced implementation with all parameters:

<?php
if (function_exists('irecommendthis')) {
    /*
     * Parameters:
     * 1. Post ID (null = current post)
     * 2. Echo output (true) or return it (false)
     * 3. Add wrapper div (true) or not (false)
     */
    irecommendthis(get_the_ID(), true, true);
}
?>

Common Integration Patterns

After Post Content

<?php
// In single.php or content.php
the_content();

if (function_exists('irecommendthis')) {
    irecommendthis();
}
?>

With Post Meta

<?php
// In content.php or similar template
?>
<div class="entry-meta">
    <?php the_category(' '); ?>
    <?php the_tags(' | Tags: ', ', ', ''); ?>
    <?php
    if (function_exists('irecommendthis')) {
        irecommendthis();
    }
    ?>
</div>

In Custom Loops

<?php
$custom_query = new WP_Query($args);
while ($custom_query->have_posts()) : $custom_query->the_post();
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <div class="excerpt">
            <?php the_excerpt(); ?>
        </div>
        <?php
        if (function_exists('irecommendthis')) {
            irecommendthis(get_the_ID(), true, true);
        }
        ?>
    </article>
    <?php
endwhile;
wp_reset_postdata();
?>

Working with the Wrapper Parameter

The third parameter controls the wrapper div:

  • true (default): Includes <div class="irecommendthis-wrapper"> around the button
  • false: No wrapper, useful when providing your own container

Custom Placement with Returned HTML

<?php
if (function_exists('irecommendthis')) {
    // Get HTML instead of echoing it (second parameter = false)
    $button = irecommendthis(get_the_ID(), false, false);
    
    // Use it in a custom layout
    echo '<div class="my-custom-actions">';
    echo '<span class="share-text">Like this article?</span>';
    echo $button;
    echo '</div>';
}
?>

Extended Customization Resources

For more advanced customization options, including hooks, filters, and detailed technical documentation, please refer to the complete plugin documentation on GitHub.

The GitHub documentation includes:

  • Complete list of action hooks and filters
  • Database structure details
  • Advanced AJAX customization
  • GDPR compliance implementation
  • Caching plugin integration

Was this article helpful? ·