KS Web Designer
Forum Replies Created
-
Forum: Plugins
In reply to: [Simple Share Buttons Adder] Google Counter not appearing at allHi David, yes you’re quite right – there was some jQuery interfering with proceedings! Sorry to have troubled you with this!
I have passed on your request to the necessary contact and will let you know what they say – thanks again!
Kev
Forum: Plugins
In reply to: [Simple Share Buttons Adder] Google Counter not appearing at allYou made me wonder myself then if I’d got the right plugin – but I’m pretty certain I have… Here’s a link, the buttons are towards the bottom of the page under the heading “Share this post”:
https://www.ks-webdesigner.com/sharebuttonsurlForum: Plugins
In reply to: [WP-PostRatings] Rating Options Show Up but Don't WorkI’m 100% sure they are both there. Can you tell me what is actually inserted into the header and footer by the plugin (or what should be inserted at least), is it just the JS file?
Forum: Plugins
In reply to: [WP-PostRatings] Rating Options Show Up but Don't WorkIt does work if I add the line of code to the twentyfourteen theme, yes. There is no page caching.
Is there anything else my theme needs to have to make the plugin work? Anything in the functions.php file perhaps?
I thought this did just that… I am using it in a slightly different way now due to the way my own site has evolved but I thought at the time it did list all posts (including those with no ratings)
I replaced <CUSTOM_POST_TYPENAME> with the name of my custom post type. So let’s say you made a new custom type called ‘shop_item’ the code I posted above would look like this:
### Function: Add Rating Custom Fields add_action('publish_post', 'add_ratings_fields'); add_action('publish_page', 'add_ratings_fields'); add_action('publish_shop_item', 'add_ratings_fields'); function add_ratings_fields($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, 'ratings_users', 0, true); add_post_meta($post_ID, 'ratings_score', 0, true); add_post_meta($post_ID, 'ratings_average', 0, true); } }
I’m afraid I can’t comment on the way this affects the widget as I’m not using it, I was creating some custom templates with these features built in.
But I hope that helps.
No problem – thanks for all your help ??
I’m afraid I couldn’t tell you – I cheat and use a plugin for my custom post types, makes it easier to manage having a nice interface to deal with the custom fields and all that.
Sorry. I can give you the name of the plugin though, and the guy that made it is incredibly helpful and would probably be happy to give you some advice for getting yours to work with custom posts.
Oh I see. Well I know when I specified a custom post type I based it on the basic functionality of a ‘post’ so perhaps that’s the reason? If the underlying functionality matches a post then that could explain why this works?
The other thing is that as far as I was aware all items have a $post_id, regardless of type? I may be wrong on that, and perhaps this falls under the same thing of my custom type being based on a ‘post’.
What do you think?
Indeed I did swap that text (all 4 instances), but worth checking for silly errors!
I tried your other suggestion but it made no difference.
Then I started tinkering. My knowledge on PHP is minimal but I thought I’d just try merging your new code with the existing code on line 532. I changed it from this:
### Function: Add Rating Custom Fields add_action('publish_post', 'add_ratings_fields'); add_action('publish_page', 'add_ratings_fields'); function add_ratings_fields($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, 'ratings_users', 0, true); add_post_meta($post_ID, 'ratings_score', 0, true); add_post_meta($post_ID, 'ratings_average', 0, true); } }
To this:
### Function: Add Rating Custom Fields add_action('publish_post', 'add_ratings_fields'); add_action('publish_page', 'add_ratings_fields'); add_action('publish_<CUSTOM_POST_TYPE_NAME>', 'add_ratings_fields'); function add_ratings_fields($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, 'ratings_users', 0, true); add_post_meta($post_ID, 'ratings_score', 0, true); add_post_meta($post_ID, 'ratings_average', 0, true); } }
And that seemed to do the trick. I just figured the two functions were largely the same, and the way WordPress handles custom post types is mostly the same as posts or pages.
I know you’re unable to test the code Lester, but is there anythign with this change that I should be careful of? As I say it all seems to work, but just in case there’s a specific reason you didn’t attempt something along these lines?
Thanks
Sorry, that still doesn’t work. The error I posted before is gone but when creating a new custom post it’s still not getting the three custom fields created (I checked the Database again after creating two new posts).
Thanks, I gave it a go but it caused the following error on my pages:
Cannot redeclare add_ratings_fields() (previously declared in /home/mti/public_html/wp-content/plugins/wp-postratings/wp-postratings.php:535)
I have had a look through phpMyAdmin. There are records for ratings_score in the wp_postmeta table (I presume this is the correct place?)
However there is no record for my new post, again, only those that have had a rating applied (either positive or negative).
Good thinking, but sadly that’s not it either. It was a possibility though. I created a new item, didn’t give it any votes and it isn’t showing up when viewing by highest rated (as above). But it appears when the sorting is not applied.
Hmmm, yeah. I have tested on the theme twentythirteen (just to make sure it wasn’t something I introduced in my custom theme), but the same issue occurs. The only thing I can think of is that it’s a problem with custom post types, as that’s what’s being displayed…?