-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override star-placement with [kkstarratings] tag? #22
Comments
Have you tried disabling the star ratings in the admin for posts/pages and used the shortcode in a post/page editor manually? |
Hi Kamal, If its a lot of work then I'll just have to go through it manually 👍 |
You could append/prepend the shortcode into all the posts programatically using php only the one time. Are you able to figure that out on your own? or do you need help in that? |
To insert the shortcode programatically use the below function in your theme folder -> functions.php file. function addShortcodeString($postType, $shortcode = '[kkstarratings]') {
foreach (get_posts(['numberposts' => -1, 'post_type' => $postType]) as $post) {
$post->post_content = $shortcode . $post->post_content;
wp_update_post($post);
}
}
// Call the function.
// 1. Pass a post type, e.g. 'post' or 'page', ...
// 2. Pass a shortcode (optional, defaults to '[kkstarratings]')
addShortcodeString('post', '[kkstarratings]'); |
Thanks a lot
Really appreciate it 😁
/Lars
… Den 25. mar. 2017 kl. 01.41 skrev Kamal Khan ***@***.***>:
To insert the shortcode programatically use the below function in your theme folder -> functions.php file.
NOTE: After placing this code in the functions.php file, refresh your website in the browser only once! After the refresh, remember to remove the code or uncomment the function call at the end. If you do not do this, the shortcode will be inserted each time you refresh your website in the browser.
function addShortcodeString($postType, $shortcode = '[kkstarratings]') {
foreach (get_posts(['numberposts' => -1, 'post_type' => $postType]) as $post) {
$post->post_content = $shortcode . $post->post_content;
wp_update_post($post);
}
}
// Call the function.
// 1. Pass a post type, e.g. 'post' or 'page', ...
// 2. Pass a shortcode (optional, defaults to '[kkstarratings]')
addShortcodeString('post', '[kkstarratings]');
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Would it be possible to allow users to use the [kkstarratings] code to override the automatic placement in a post?
I really love the plugin and like that you may exclude categories. As I have just begun using the plugin it's nice that all posts now have the ability to be "rated". However, I really would love the option to insert the "ratings" on specific places in some posts with the [kkstarratings] tag.
Would it be possible to change the code so that if a [kkstarratings] is in the text the automatic insertion (chosen in settings) would be left out?
Does it make sense?
I really hope that it is possible... :-)
Best wishes
Lars
The text was updated successfully, but these errors were encountered: