Show The Term Description on All Paginated Pages of an Archive

This free tutorial shows you how to modify the term description for product categories and tag archives, so it displays on all pages of a paginated archive, not just the first page, which is default WooCommerce behavior.

There’s 3 simple steps we need to take to :

  1. Find the default function, in WooCommerce, which generates our product category archive description.
  2. Find the action hook, in WooCommerce, which controls the default output location of the default function.
  3. Remove the default function, modify the default function and rename it, add back the new modified custom function.

The following video explains in very simple terms, the steps you need to take to find, modify and change the default output of your archive description on your product category and tag ( taxonomy ) archive pages.

Don’t have time to learn how to modify WooCommerce code? Click the Add to Cart button and download the code for free.

Default Functions

The default function name for the term description is named woocommerce_taxonomy_archive_description.

The action hook, in WooCommerce, which controls where and when the default function executes, is named woocommerce_archive_description.

You can also see the do_action hook woocommerce_archive_description on line 44 of archive-product.php file.

Code Explanation

Lets take a deeper look into the code which we have removed from the default function for the archive description which is :

0 === absint( get_query_var( 'paged' ) )

1. get_query_var('paged') : This function retrieves the value of the specified query variable, in this case, paged. The paged variable is often used in pagination scenarios to determine which page of a set of results is being requested.

2. absint() : This function stands for “absolute integer” and is used to convert a value to its absolute integer representation. It ensures that the returned value is a non-negative integer.

3. 0 === ... : This is a comparison statement in PHP. It checks if the result of absint( get_query_var('paged') ) is identical (both in value and type) to 0.

In summary, this code checks if the absolute integer value of the paged query variable is exactly equal to 0. If it is, the whole expression will evaluate too true; otherwise, it will evaluate too false.

The purpose of this code is to check if the current page being requested is the first page in a paginated archive set for taxonomy type archive pages in WooCommerce. If paged is 0, it typically means the user is on the initial or 1st page of the archive.

Review

Using the code? If you are using the code from this post, please leave a review.

Download Folder

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.