Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Stephen S

    (@ssuess)

    I think I have just found the answer: no, not out of the box. But if one goes to line 353 of ajax-hits-counter.php, and changes this:

    if( isset($_POST['post_type']) && in_array( $_POST['post_type'], array( 'post', 'page' ) ) )

    to something like this:

    if( isset($_POST['post_type']) && in_array( $_POST['post_type'], array( 'post', 'page','my_custom_post_type' ) ) )

    And then sets the widget to get “Pages and Posts”, it will work.

    Thread Starter Stephen S

    (@ssuess)

    ignore above, I was totally wrong. It is line 886, change:

    p.post_type = \'post\'';

    to

    p.post_type in ( \'post\',\'my_custom_post_type\')';

    And then just select posts for display (not pages and posts)

    Thread Starter Stephen S

    (@ssuess)

    Well, I needed to take this a step further to be able to add custom post types and pull them out separately, not just as a group. So here is what I did (hope this helps someone else):

    1. Around line 1477, add your extra types. just copy the line from post type 2:

    '<option value="2"'.( $post_type==2 ? ' selected="selected"' : '' ).'>'.__( 'Pages only', $this->plugin_alias ).'</option>'.

    and add one line for each type you need.

    2. around line 889, add a new case type for each new post type, and make the number correspond as with the others.

    3. VERY IMPORTANT: around line 1277 (or 1278) change this line:

    'post_type'                     => intval( preg_replace( '#[^012]#', '', $new_instance['post_type'] ) ),

    to something like

    'post_type'                     => intval( preg_replace( '#[^01234567]#', '', $new_instance['post_type'] ) ),

    add a number for each of your post types.

    Et Voila! Now in the widget you can pick from any of your defined post types…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post types?’ is closed to new replies.