Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function wpf_apply_tags_on_view( $post ) {
- if( ! function_exists( 'wp_fusion' ) ) {
- return;
- }
- if ( is_admin() || ! is_singular() || ! is_user_logged_in() || $post->post_type != 'post' ) {
- return;
- }
- $tags_to_apply = array();
- $categories = get_the_terms( $post, 'category' );
- if( ! empty( $categories ) && ! is_wp_error( $categories ) ) {
- foreach( $categories as $category ) {
- $tags_to_apply[] = $category->name;
- }
- }
- $tags = get_the_terms( $post, 'post_tag' );
- if( ! empty( $tags ) && ! is_wp_error( $tags ) ) {
- foreach( $tags as $tag ) {
- $tags_to_apply[] = $tag->name;
- }
- }
- wp_fusion()->user->apply_tags( $apply_tags );
- }
- add_action( 'the_post', 'wpf_apply_tags_on_view' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement