The $mod Variable

The $mod variable is defined early in the WPSSO load process (in WpssoHead->show_head(), which is hooked to the 'wp_head' action) and is passed to most WPSSO methods and filters.

The $mod variable name stands for module and defines important reference values for the current WPSSO object type. The WPSSO object type can be a comment, post, term, or user. An archive does not have an object type since an archive page is a collection of object types. For example, a monthly archive is a collection of posts for that month. In this case, $mod[ 'obj' ] would be false and other properties would be true, like $mod[ 'is_archive' ], $mod[ 'is_date' ], and $mod[ 'is_month' ].

The WpssoPage->get_mod() method can be used to determine the current webpage module. If you need to setup a $mod variable for a specific comment, post, term, or user, you can call the get_mod() methods from those class objects directly.

Here is a $mod array for an example post:

An example to retrieve custom post meta:

The 'obj' element can be used to call object methods. Here's an example to get a custom Open Graph description value (if one has been defined):

Function wrappers for the WPSSO get_mod() methods are also available:

Leave a Review