• Resolved J

    (@paradox_designs)


    Hi,

    Love the simplicity and flexibility of this plugin. It is the only one that seems to do exactly what i need it to.

    However i can get it to work on posts (just as a test) but i cannot get it to work on the custom post type that comes with the Divi theme. In automatic it doesn’t show up and if I set it to manual and add <?php if(function_exists(‘spr_show_rating’)){echo spr_show_rating();}?> to the single-project.php template file that displays the project page (custom post type page) nothing shows up. Tried playing around with all the settings but no go.

    Please advise.

    Thanks

    https://wordpress.org/plugins/simple-rating/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter J

    (@paradox_designs)

    I should add that the meta box with the stats doesn’t get added in the backend either when i edit each Class page (and i do need it).

    Last point that might be relevant. I changed the name of this type of custom post type from it’s normal name Projects to Classes using this. I don’t think it should have affected it but it is possible that this is somehow the issue.

    Once again, thanks in advance for the help!

    Plugin Author Igor Yavych

    (@flyerua)

    Hi. You’ve checked this cpt in options?
    If so, it might be due to bug in older version (fixed in 1.5).
    Assuming you have version 1.4 installed, you should be able to fix it like so:
    1. Open rating.php
    2. Go to line ~931
    3. Replace spr_get_post_types_fo() function with

    function spr_get_post_types_fo()
    {
        $options=spr_options();
        $post_types=get_post_types(array('public'=>true, '_builtin'=>false), 'objects', 'and');
        $result='<table><tr><td class="spr_cb_labels">Posts</td><td><input type="checkbox" name="post" id="post" value="'.$options['where_to_show']['post'].'" '.checked($options['where_to_show']['post'], 1, false).'></td></tr><tr><td class="spr_cb_labels">Pages</td><td><input type="checkbox" name="page" id="page" value="'.$options['where_to_show']['page'].'" '.checked($options['where_to_show']['page'], 1, false).'></td></tr>';
        foreach ($post_types as $type)
        {
            if (!isset($options['where_to_show'][$type->name]))
            {
                $options['where_to_show'][$type->name]=0;
            }
            $result.= '<tr><td class="spr_cb_labels">'.$type->labels->name.'</td><td><input type="checkbox" name="'.$type->name.'" id="'.$type->name.'" value="'.$options['where_to_show'][$type->name].'" '.checked($options['where_to_show'][$type->name], 1, false).'></td></tr>';
        }
        $result.="</table>";
        return $result;
    }

    4. After that, there is spr_list_cpt_slugs() function, replace it with

    $types=array("post", "page");
        $post_types=get_post_types(array('public'=>true, '_builtin'=>false), 'objects', 'and');
        foreach ($post_types as $type)
        {
            $types[]=$type->name;
        }
        return $types;

    5. If you use top rated content, open spr_widgets.php, and replace line 124 with

    $result.= '<tr><td class="spr_cb_labels">'.$post_type->labels->name.'</td><td><input type="checkbox" style="float:right;" name="'.$this->get_field_name($post_type->name).'" id="'.$this->get_field_id($post_type->name).'" value="'.$options[$post_type->name].'" '.checked($options[$post_type->name], 1, false).'></td></tr>';

    Make sure to go to options again and check this cpt of yours. Do that for widgeet too if you’re using it.
    P.S. Glad you like it. Hope you will try version 1.5 when it comes out. It got lots of fixes, improvements, new features and other nice stuff 😉

    Thread Starter J

    (@paradox_designs)

    Thanks. that worked.

    But now it causes a responsive wistia video embed code to break, but only when i am logged in. Have no clue why. any idea?

    Looking forward to 1.5

    Plugin Author Igor Yavych

    (@flyerua)

    Can you give me a link to where it happens?
    I can’t say without taking a look.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cannot get it to work on custom post type’ is closed to new replies.