Shortcodes

You can also output Helpful using shortcodes on your page. This is useful if you only want to show Helpful in certain places. The basic shortcode looks like this:

[helpful]

Was this post helpful?

You can also change individual parameters. Actually, you can change almost anything, but this could break Helpful, here’s an example of how to change the heading:

[helpful heading="My new heading!"]

My new heading!

Default Values

$defaults = [
    'heading' => string,
    'content' => string,
    'button_pro' => string,
    'button_contra' => string,
    'counter' => bool,
    'count_pro' => Helpful\Core\Helpers\Stats::get_pro($post_id),
    'count_pro_percent' => Helpful\Core\Helpers\Stats::get_pro($post_id, true),
    'count_contra' => Helpful\Core\Helpers\Stats::get_contra($post_id),
    'count_contra_percent' => Helpful\Core\Helpers\Stats::get_contra($post_id, true),
    'credits' => bool,
    'credits_html' => string,
    'exists' => int (1/0),
    'exists_text' => string,
    'post_id' => integer,
];

With this you can adjust the shortcode. For example if we want to change the text for the Pro Button:

[helpful button_pro="good" button_contra="bad"]

Was this post helpful?

If you want to use the shortcode with PHP, it works like this:

echo do_shortcode('[helpful button_pro="yes" button_contra="no"]');

Was this post helpful?

Top