Ok answering my own question here…
To add your custom post type to the category listing you need to add the ‘taxonomies’ => array(‘category’) to your register post type initially. Then create a post category you want to use for it. and assign that category on post creation.
Then add a function to append the query that goes after categories to include your custom post type.
function my_custom_type_in_categories( $query ) {
if ( $query->is_main_query()
&& ( $query->is_category() || $query->is_tag() ) ) {
$query->set( 'post_type', array( 'post', 'mw' ) );
}
}
add_action( 'pre_get_posts', 'my_custom_type_in_categories' );
So in this case I am adding an action whenever anything in WP goes after the get posts and category or tag is specified amd changing the query set to include both post which is the standard and my custom post type of ‘mw’. Doing this I now see this custom post type in the reporting on slimstats and the category filter works in all of WP as well. Add all your custom post types to this as members of the array.
Happy Coding!
Ok well I was wrong.. The above did the trick for WP and did add it to the listing in SlimStats and to the wp_slim_content_info table but it is not adding any content id’s and tracking anything. In looking at the slimstat code it looks like you are handling custom post types some how with cpt:$post_type but I can’t figure it out yet.
Any help please?
So do I just ask stupid questions? Am I rude? Or are they to hard to answer?
I have not gotten a response from the author on any of my questions and have found a way to do each thing on my own but it would be awesome to at least get a response.
If anyone would like to know an easy way to pull slimstat into a custom post type that doesn’t use the entirety of wp_footer and adds tracking of individual clicks without slowing down the page they are on just ask, I will respond.
Hey there,
it’s not a matter of asking stupid questions, but of understanding that this is done for free during my spare time. A little more patience would be greatly appreciated.
As for your question, you need to call wp_footer to make SlimStat work, at least for now. There’s no way around it.
Cheers,
Camu