The archive page is shown when a category is selected and typically has excerpts of each post in that category
Category page hook
add_filter('the_content', 'our_modify_category_content');
function our_modify_category_content ($Content)
{
//Exit if not category
if (!is_category() || !is_main_query())
return($Content);
//$Category = get_queried_object();
//$CategoryName = $Category->name;
$Output = '';
$Output .= '[Inserting at start]<br>';
$Output .= $Content;
$Output .= '[Inserting at end]';
return $Output;
}
Doesn’t work?
Maybe your theme has overridden the default WordPress category pages with its own custom category page?
Theme hooks
Look in your theme’s archive.php (or category.php) file – does it have any hooks?
Kleo theme example hook functions
//****************************************************************
//****************************************************************
//********** WP CATEGORY ARCHIVE PAGE - BEFORE CONTENT ***********
//****************************************************************
//****************************************************************
add_action( 'kleo_before_archive_content', 'odac_kleo_before_archive_content' ); //kleo_before_archive_content is a hook kleo has in its archive.php
function odac_kleo_before_archive_content( )
{
//-----------------------
//----- HTML OUTPUT -----
//-----------------------
$HtmlOutput = "";
//----- DISPLAY THE CATEGORY TITLE -----
if (is_archive())
{
$current_category = single_cat_title("", false);
$HtmlOutput .= "<h1>$current_category</h1>";
}
echo $HtmlOutput;
}
//***************************************************************
//***************************************************************
//********** WP CATEGORY ARCHIVE PAGE - AFTER CONTENT ***********
//***************************************************************
//***************************************************************
add_action( 'kleo_after_archive_content', 'odac_kleo_after_archive_content' ); //kleo_after_archive_content is a hook kleo has in its archive.php
function odac_kleo_after_archive_content( )
{
//-----------------------
//----- HTML OUTPUT -----
//-----------------------
$HtmlOutput = "";
//----- DISPLAY THE HOME AND BACK BUTTONS -----
if (is_archive())
{
$HtmlOutput .= "THE END";
}
echo $HtmlOutput;
}
