Hook into archive / category template
-
Hi,
I’m trying to display custom content from my event plugin on the archive/category page. So I hook into the the_content filter:
function archive_content( $content ) { $var1 = esc_attr__( 'First var', 'textdomain' ); $var2 = esc_attr__( 'Second var', 'textdomain' ); if (get_post_type() == 'event' && is_archive()) { $content = '<div id="mydiv">' . '<div class="myvar">' . $var1 . $var2 . '</div>' . $content . '</div>'; } return $content; } add_filter( 'the_content', 'archive_content' );
This works, “First var” and “Second var” (and the default post content) are displayed when viewing the archive/category page.
BUT, no styling is applied (no id and class in source code either). It’s all stripped. How come?
Guido
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Hook into archive / category template’ is closed to new replies.