Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: get_the_category experiment
- Plugin URI: https://www.damiencarbery.com
- Description: Experiment with get_the_category() function.
- Author: Damien Carbery
- Version: 0.1
- */
- add_filter( 'the_content', 'append_get_the_category' );
- function append_get_the_category( $content ) {
- if ( !is_single() ) return $content;
- $post_categories = get_the_category();
- $categories = array();
- foreach ( $post_categories as $category ) {
- $categories[] = sprintf( '<a href="%s" class="cat-%s">%s</a>', esc_url( get_category_link( $category->term_id ) ), $category->slug, $category->name );
- }
- return $content . implode( ' ', $categories );
- }
- /*
- WP_Term::__set_state(array(
- 'term_id' => 24,
- 'name' => 'Foo Parent',
- 'slug' => 'foo-parent',
- 'term_group' => 0,
- 'term_taxonomy_id' => 24,
- 'taxonomy' => 'category',
- 'description' => '',
- 'parent' => 0,
- 'count' => 1,
- 'filter' => 'raw',
- 'cat_ID' => 24,
- 'category_count' => 1,
- 'category_description' => '',
- 'cat_name' => 'Foo Parent',
- 'category_nicename' => 'foo-parent',
- 'category_parent' => 0,
- )),*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement