Forums

[Plugin: WP-PostRatings] How to remove custom fields? (20 posts)

  1. juicyart
    Member
    Posted 1 year ago #

    I display custom fields at the bottom of my articles, and with this plugin activated if there is a rating on the article it shows 3 custom fields from the plugin with my other custom fields - ratings_average, ratings_score, ratings_users. How do I stop these from showing up with my other keys? See this page:

    http://www.haveakillertime.com/bars/80

    http://wordpress.org/extend/plugins/wp-postratings/

  2. juicyart
    Member
    Posted 1 year ago #

    I should also mention that deleting those keys from the post they show up in resets the rating, and continues displaying those fields with "0" next to them

  3. xdesi
    Member
    Posted 1 year ago #

    What's wrong with them showing up there?

  4. juicyart
    Member
    Posted 1 year ago #

    It already shows the plugin the way it's intended at the bottom of the articles where I placed it. I don't want ratings_average, ratings_score, and ratings_users showing up in my list of custom fields. I don't think they're even supposed to be there anyway, given their appearance

  5. xdesi
    Member
    Posted 1 year ago #

    They are supposed to be there, it's incase you want to forge the ratings and change them to make the ratings better. So you have control over them.

    It's not as though the user can see these fields it's only on admin screen, and there for your benefit. What problem is it actually causing you I don't understand

  6. juicyart
    Member
    Posted 1 year ago #

    Sorry but you're wrong - they show up in the list at the bottom of that article even if I'm not logged in. So yes, they are causing me a problem because like I said I don't want them showing up in my list of custom fields at the bottom of articles. If you're not going to offer help then don't bother responding to me. I didn't ask a legitimate question because I wanted to argue with a random WP user - I asked for help

  7. xdesi
    Member
    Posted 1 year ago #

    :) I'm not arguing with you here, i'm just trying to distinguish the problem..

    So if I go onto:
    http://www.haveakillertime.com/bars/80

    I should be able to see some fields at the bottom of the page: ratings_average, ratings_score, and ratings_users ?

    If so I can't see it?

  8. juicyart
    Member
    Posted 1 year ago #

    I just deleted 2 sections of code out of the php file for adding custom fields, then I cleared the custom fields from the post so that's why they're gone. Try rating it and refresh the page to see if they show up

    edit: doing that caused it to stop saving the ratings. Lovely. Time to try something else

  9. xdesi
    Member
    Posted 1 year ago #

    Well I can't see the problem visually at the moment, i tried the refresh.

    What are you using to display your custom fields, a plugin that displays all custom fields attached to a post?
    Or some PHP code that displays all custom fields to a post?

    If so post it up.

    Also

    On http://www.haveakillertime.com/bars/80 what are your other custom fields that should be displaying apart from the ratings fields.

  10. juicyart
    Member
    Posted 1 year ago #

    Just using the basic show post meta tag or whatever it is, so of course it shows all the custom fields for the post. I'm just trying to stop the rating plugin from adding custom fields in the first place. If nothing else, I'm going to have to create "Show" tags for each individual field and get rid of the general one
    Here are the custom fields for the lodo's review:

    Address:
    1946 Market St
    Denver, CO 80202
    (303) 293-8555
    Alcohol: Full Bar
    Attire: Casual
    Cover: $2
    Credit Card Accepted: Yes
    Good for Groups: Very
    Outdoor Seating: Yes
    Waiter Service: Yes
    Wheelchair Accessible: Yes

    If you can't see those I can't imagine why. I've viewed this page on FF2, FF3, IE6, IE7, Opera, and Safari on computers running Vista, XP, and a Mac, all while not being logged in and everything displays fine.

  11. juicyart
    Member
    Posted 1 year ago #

    It looks like the plugin stores all rating info in the custom field meta tags instead of storing the ratings in a database, so I'm gonna have to do what I mentioned and change the show meta tags.

  12. xdesi
    Member
    Posted 1 year ago #

    Yes I understand you now.

    Well I think that the custom fields are required for WP-PostRatings to work correctly, I may be wrong but if this is the case then you must change your code to just retrieve the custom fields you want.

    So at the start of the loop we have define all the custom fields you want to show

    <?php if (have_posts()) : while (have_posts()) : the_post();
    $custm1 = get_post_meta($post->ID, 'custm1', $single = true);
    $custm2 = get_post_meta($post->ID, 'custm2', $single = true);
    $custm3 = get_post_meta($post->ID, 'custm3', $single = true);
    $custm4 = get_post_meta($post->ID, 'custm4', $single = true);
    	 ?>

    All you do here is change the names of custm1-4 to the exact name of your custom field key..
    Then you just display them wherever later on in the template like this:
    <?php echo $custm1; ?>
    Where custm1 is the name of your Custom Field Key. This will then output the value for this key for the post in question.

    Sorry if you are already doing this,

  13. juicyart
    Member
    Posted 1 year ago #

    So I place that code at the start of the loop and that's it? Or do I place it where I want the list to appear in the loop?

    Thank you for that, I was actually just looking up how to do that so you saved me some time.

  14. juicyart
    Member
    Posted 1 year ago #

    Never mind I misread that. I put the first code section in the beginning of the loop then the echo where I want it to display

  15. juicyart
    Member
    Posted 1 year ago #

    Well I couldn't get your code sample to work, so I found another way around the problem until I figure out how to put all my keys in 2 columns. What I did was add _ to the beginning of each custom field name in the code for the plugin so that none of its custom fields will display on the pages or on the post edit screen. This will be handy even after I get my column thing figured out so that none of my writers can manually edit ratings ;)

  16. xdesi
    Member
    Posted 1 year ago #

    At the start of the loop you define all the custom fields you want to show, as in the example. Make sure you replace 'custm1' and so on with the exact name of your custom field keys as in Wordpress.

    Then you simply echo it out as in the second example wherever you want it to appear.So would be something like this in your example:
    Address: <?php echo $address; ?>
    Alcohol: <?php echo $alc; ?>
    Attire: <?php echo $cas; ?>
    Cover: <?php echo $cover; ?>
    Credit Card Accepted: <?php echo $cc; ?>
    and so on..

    However remember the $address you would replace with the exact name of what you've called it earlier on.

  17. juicyart
    Member
    Posted 1 year ago #

    will that show the key name & key value the way it shows when I just use the_meta? Or does it just show the value of the key?

  18. xdesi
    Member
    Posted 1 year ago #

    You can just add the key name yourself inside the template or is it a different keys on different posts?
    The code i posted is just retrieving the value, there's probably one to get the name also but not sure of what it is.

  19. ukickarse
    Member
    Posted 8 months ago #

    There's probably a better way to do this, but here's something I came up with. Hope this helps.

    Replace <?php the_meta(); ?> with this:

    <ul>
    <?php
      $custom_fields = get_post_custom($post->ID);
      $custom_field_keys = get_post_custom_keys();
      foreach ( $custom_field_keys as $key => $name ) {
        $valuet = trim($name);
    	if ( '_' == $valuet{0} ){
    		continue;
    	}
    	if ($name != "ratings_users" && $name != "ratings_score" && $name != "ratings_average"){
    		echo "<li>";
    		echo "<strong>" . $name . ":</strong> ";
    		$my_custom_field = $custom_fields[$name];
    		foreach ( $my_custom_field as $key => $value )
    			echo $value . "</li>";
    	}
      }
    ?>
    </ul>
  20. RachelKaye
    Member
    Posted 2 months ago #

    Thanks for that code ukickarse, I was having this same problem and it works :)

Topic Closed

This topic has been closed to new replies.

About this Topic