WPIntell

Source evidence

I could use sample code for enabling EPR with CPTs

External Permalinks Redux · support · 2014-04-10T15:41:00+00:00

complaintsentiment
mediumseverity
0.8relevance
4replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

2 / 22 rows with source links

9.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

20 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
kato unresolved
I’ve been trying to hook into epr_post_types in my functions.php to work with a custom post type called “reports.” Is there example working code that a less-experienced coder can use to get it working? Thanks. https://wordpress.org/plugins/external-permalinks-redux/ FWIW – future strugglers, it’s butt-simple to edit line 93 of the plug-in to something like this: $post_types = apply_filters( ‘epr_post_types’, array( ‘post’, ‘page’, ‘report’ ) ); It works, just replace ‘report’ above with your CPT name. It would be nice to do this the proper way, but for now, it’s working. Or, to make it work with all post types, change line 93 to: $post_types = array_values( get_post_types( array( ‘public’ => true, ‘_builtin’ => false ), ‘names’ ) ); Although I’m not sure that wouldn’t bloat the bejeezus out of your database. This seems to work for me add_filter( 'epr_post_types', 'my_function' ); function my_function( $content_types ){ $content_types = array('my_content_type'); return $content_types; } That works, thank you!

Comments

4 shown
kato 2014-04-10T15:45:00+00:00

FWIW – future strugglers, it’s butt-simple to edit line 93 of the plug-in to something like this: $post_types = apply_filters( ‘epr_post_types’, array( ‘post’, ‘page’, ‘report’ ) ); It works, just replace ‘report’ above with your CPT name. It would be nice to do this the proper way, but for now, it’s working.

kato 2014-04-10T15:53:00+00:00

Or, to make it work with all post types, change line 93 to: $post_types = array_values( get_post_types( array( ‘public’ => true, ‘_builtin’ => false ), ‘names’ ) ); Although I’m not sure that wouldn’t bloat the bejeezus out of your database.

dravidian7 2014-04-24T15:37:00+00:00

This seems to work for me add_filter( 'epr_post_types', 'my_function' ); function my_function( $content_types ){ $content_types = array('my_content_type'); return $content_types; }

kato 2014-04-24T19:53:00+00:00

That works, thank you!