Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //=======================================
- //Community Posts Permalink Manipulation
- //=======================================
- //fix archive pagination issue.
- function community_posts_disable_redirect_canonical($redirect_url) {
- //TODO double check the rules are fine.
- if (is_singular('community_post') || is_page_template('templates/community.php')) $redirect_url = false;
- return $redirect_url;
- }
- //dynamic permalink by community_post_domain slug
- function wpa_show_permalinks( $post_link, $post ){
- if ( is_object( $post ) && $post->post_type == 'community_post' ){
- //get the community post domain term (for example: devops)
- $terms = wp_get_object_terms( $post->ID, 'community_post_domain' );
- if( $terms ){
- return str_replace( '%community_post_domain%' , $terms[0]->slug , $post_link );
- }
- }
- return $post_link;
- }
- add_filter('redirect_canonical','community_posts_disable_redirect_canonical');
- add_filter( 'post_type_link', 'wpa_show_permalinks', 1, 2 );
- //==============================================
- // END - Community Posts Permalink Manipulation
- //==============================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement