wp_get_post_tags example



        $post = get_post( $comment['comment_post_ID'] );

        if ( ! is_null( $post ) ) {
            // $post can technically be null, although in the past, it's always been an indicator of another plugin interfering.             $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;

            // Tags and categories are important context in which to consider the comment.             $comment['comment_context'] = array();

            $tag_names = wp_get_post_tags( $post->ID, array( 'fields' => 'names' ) );

            if ( $tag_names && ! is_wp_error( $tag_names ) ) {
                foreach ( $tag_names as $tag_name ) {
                    $comment['comment_context'][] = $tag_name;
                }
            }

            $category_names = wp_get_post_categories( $post->ID, array( 'fields' => 'names' ) );

            if ( $category_names && ! is_wp_error( $category_names ) ) {
                foreach ( $category_names as $category_name ) {
                    
$post_date_gmt     = $this->_convert_date_gmt( $postdata['post_date_gmt']$postdata['post_date'] );
            $post_modified     = $this->_convert_date( $postdata['post_modified'] );
            $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt']$postdata['post_modified'] );

            $categories = array();
            $catids     = wp_get_post_categories( $post_id );
            foreach ( $catids as $catid ) {
                $categories[] = get_cat_name( $catid );
            }

            $tagnames = array();
            $tags     = wp_get_post_tags( $post_id );
            if ( ! empty( $tags ) ) {
                foreach ( $tags as $tag ) {
                    $tagnames[] = $tag->name;
                }
                $tagnames = implode( ', ', $tagnames );
            } else {
                $tagnames = '';
            }

            $post = get_extended( $postdata['post_content'] );
            $link = get_permalink( $postdata['ID'] );

            
Home | Imprint | This part of the site doesn't use cookies.