{"id":2891,"date":"2020-06-18T19:46:17","date_gmt":"2020-06-18T18:46:17","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2891"},"modified":"2025-05-13T11:17:04","modified_gmt":"2025-05-13T10:17:04","slug":"archive-page-actions","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/actions\/archive-page-actions","title":{"rendered":"Category\/archive page actions"},"content":{"rendered":"\n<p>The archive page is shown when a category is selected and typically has excerpts of each post in that category<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Category page hook<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('the_content', 'our_modify_category_content');\nfunction our_modify_category_content ($Content)\n{\n  \n  \/\/Exit if not category\n  if (!is_category() || !is_main_query())\n    return($Content);\n\n  \/\/$Category = get_queried_object();\n  \/\/$CategoryName = $Category-&gt;name;\n\n  $Output = '';\n  $Output .= '&#91;Inserting at start]&lt;br&gt;';\n  $Output .= $Content;\n  $Output .= '&#91;Inserting at end]';\n  return $Output;\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Doesn&#8217;t work?<\/h5>\n\n\n\n<p>Maybe your theme has overridden the default WordPress category pages with its own custom category page?<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Theme hooks<\/h4>\n\n\n\n<p>Look in your theme&#8217;s archive.php (or category.php) file &#8211; does it have any hooks?<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Kleo theme example hook functions<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/****************************************************************\n\/\/****************************************************************\n\/\/********** WP CATEGORY ARCHIVE PAGE - BEFORE CONTENT ***********\n\/\/****************************************************************\n\/\/****************************************************************\nadd_action( 'kleo_before_archive_content', 'odac_kleo_before_archive_content' );     \/\/kleo_before_archive_content is a hook kleo has in its archive.php\nfunction odac_kleo_before_archive_content( )\n{\n  \n  \/\/-----------------------\n  \/\/----- HTML OUTPUT -----\n  \/\/-----------------------\n  \n  $HtmlOutput = \"\";\n  \n  \/\/----- DISPLAY THE CATEGORY TITLE -----\n  if (is_archive())\n  {\n    $current_category = single_cat_title(\"\", false);\n    \n    $HtmlOutput .= \"&lt;h1&gt;$current_category&lt;\/h1&gt;\";\n  }\n  \n  echo $HtmlOutput;\n}\n\n\n\/\/***************************************************************\n\/\/***************************************************************\n\/\/********** WP CATEGORY ARCHIVE PAGE - AFTER CONTENT ***********\n\/\/***************************************************************\n\/\/***************************************************************\nadd_action( 'kleo_after_archive_content', 'odac_kleo_after_archive_content' );     \/\/kleo_after_archive_content is a hook kleo has in its archive.php\nfunction odac_kleo_after_archive_content( )\n{\n  \n  \/\/-----------------------\n  \/\/----- HTML OUTPUT -----\n  \/\/-----------------------\n  \n  $HtmlOutput = \"\";\n  \n  \/\/----- DISPLAY THE HOME AND BACK BUTTONS -----\n  if (is_archive())\n  {\n    $HtmlOutput .= \"THE END\";\n  }\n  \n  echo $HtmlOutput;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The archive page is shown when a category is selected and typically has excerpts of each post in that category Category page hook Doesn&#8217;t work? Maybe your theme has overridden the default WordPress category pages with its own custom category page? Theme hooks Look in your theme&#8217;s archive.php (or category.php) file &#8211; does it have [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[309],"tags":[],"class_list":["post-2891","post","type-post","status-publish","format-standard","hentry","category-actions"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2891"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2891\/revisions"}],"predecessor-version":[{"id":5020,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2891\/revisions\/5020"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}