# wpsso/trunk/html/mod-variable.html

WPSSO Core – Complete Schema Markup and Meta Tags, version trunk. 234 lines.

- Page: https://pluginprobe.com/plugins/wpsso/trunk/code/html/mod-variable.html
- Raw: https://pluginprobe.com/plugins/wpsso/trunk/raw/html/mod-variable.html
- Modified: 2024-01-04T15:44:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpsso/trunk/code/html/mod-variable.html#L10-L20`.

```html

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

<pre>
$wpsso =&amp; Wpsso::get_instance();

// In case we prefer using the global $post object.
$use_post = apply_filters( 'wpsso_use_post', in_the_loop() ? true : false );

// Get information about the current webpage.
$mod = $wpsso-&gt;page-&gt;get_mod( $use_post );
</pre>

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

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

<pre>
$wpsso =&amp; Wpsso::get_instance();

// Get information for comment ID 123.
$mod = $wpsso-&gt;comment-&gt;get_mod( $comment_id = 123 );

// Get information for post ID 123.
$mod = $wpsso-&gt;post-&gt;get_mod( $post_id = 123 );

// Get information for term ID 123.
$mod = $wpsso-&gt;term-&gt;get_mod( $term_id = 123 );

// Get information for user ID 123.
$mod = $wpsso-&gt;user-&gt;get_mod( $user_id = 123 );
</pre>

<p>Functions to get the <code>$mod</code> array are also available:</p>

<pre>
// Get information about the current webpage (post, term, user, archive page, etc.).
$mod = wpsso_get_page_mod();

// Get information for comment ID 123.
$mod = wpsso_get_comment_mod( $comment_id = 123 );

// Get information for post ID 123.
$mod = wpsso_get_post_mod( $post_id = 123 );

// Get information for term ID 123.
$mod = wpsso_get_term_mod( $term_id = 123 );

// Get information for user ID 123.
$mod = wpsso_get_user_mod( $user_id = 123 );
</pre>

<p>Here is an example <code>$mod</code> array for a post:</p>

<pre>Array (
    [id] =&gt; 123
    [name] =&gt; post
    [name_transl] =&gt; post
    [obj] =&gt; object WpssoPost
    [wp_obj] =&gt; object WP_Post
    [query_vars] =&gt; Array ()
    [posts_args] =&gt; Array ()
    [paged] =&gt; false
    [paged_total] =&gt; 1
    [is_404] =&gt; false
    [is_archive] =&gt; false
    [is_attachment] =&gt; false
    [is_comment] =&gt; false
    [is_date] =&gt; false
    [is_day] =&gt; false
    [is_home] =&gt; false
    [is_home_page] =&gt; false
    [is_home_posts] =&gt; false
    [is_month] =&gt; false
    [is_post] =&gt; true
    [is_post_type_archive] =&gt; false
    [is_public] =&gt; false
    [is_search] =&gt; false
    [is_term] =&gt; false
    [is_user] =&gt; false
    [is_year] =&gt; false
    [comment_author] =&gt; false
    [comment_author_name] =&gt; false
    [comment_author_url] =&gt; false
    [comment_paged] =&gt; false
    [comment_parent] =&gt; false
    [comment_rating] =&gt; false
    [comment_time] =&gt; false
    [use_post] =&gt; false
    [post_slug] =&gt; the-post-slug
    [post_type] =&gt; post
    [post_type_label_plural] =&gt; Posts
    [post_type_label_single] =&gt; Post
    [post_mime_type] =&gt; ''
    [post_mime_group] =&gt; ''
    [post_mime_subgroup] =&gt; ''
    [post_status] =&gt; publish
    [post_author] =&gt; 123
    [post_coauthors] =&gt; Array ()
    [post_time] =&gt; 2013-03-15T22:23:27+00:00
    [post_timestamp] =&gt; 1363386207
    [post_modified_time] =&gt; 2021-01-31T00:16:46+00:00
    [post_modified_timestamp] =&gt; 1612052206
    [post_parent] =&gt; false
    [tax_slug] =&gt; ''
    [tax_label_plural] =&gt; false
    [tax_label_single] =&gt; false
    [user_name] =&gt; ''
    [wpml_code] =&gt; ''
)</pre>

<p>Here is an example <code>$mod</code> array for a WooCommerce product:</p>

<pre>Array (
    [id] =&gt; 4567
    [name] =&gt; post
    [name_transl] =&gt; post
    [obj] =&gt; object WpssoPost
    [wp_obj] =&gt; object WP_Post
    [query_vars] =&gt; Array ()
    [posts_args] =&gt; Array ()
    [paged] =&gt; false
    [paged_total] =&gt; 1
    [is_404] =&gt; false
    [is_archive] =&gt; false
    [is_attachment] =&gt; false
    [is_comment] =&gt; false
    [is_date] =&gt; false
    [is_day] =&gt; false
    [is_feed] =&gt; false
    [is_home] =&gt; false
    [is_home_page] =&gt; false
    [is_home_posts] =&gt; false
    [is_month] =&gt; false
    [is_post] =&gt; true
    [is_post_type_archive] =&gt; false
    [is_public] =&gt; true
    [is_search] =&gt; false
    [is_term] =&gt; false
    [is_user] =&gt; false
    [is_year] =&gt; false
    [comment_author] =&gt; false
    [comment_author_name] =&gt; false
    [comment_author_url] =&gt; false
    [comment_paged] =&gt; false
    [comment_parent] =&gt; false
    [comment_rating] =&gt; false
    [comment_time] =&gt; false
    [use_post] =&gt; false
    [post_slug] =&gt; hoodie
    [post_type] =&gt; product
    [post_type_label_plural] =&gt; Products
    [post_type_label_single] =&gt; Product
    [post_mime_type] =&gt; ''
    [post_mime_group] =&gt; false
    [post_mime_subgroup] =&gt; false
    [post_status] =&gt; publish
    [post_author] =&gt; 123
    [post_coauthors] =&gt; Array ()
    [post_time] =&gt; 2023-02-16T12:34:11+00:00
    [post_timestamp] =&gt; 1676550851
    [post_modified_time] =&gt; 2023-07-04T00:54:41+00:00
    [post_modified_timestamp] =&gt; 1688432081
    [post_parent] =&gt; false
    [term_tax_id] =&gt; false
    [tax_slug] =&gt; ''
    [tax_label_plural] =&gt; false
    [tax_label_single] =&gt; false
    [user_name] =&gt; ''
    [wpml_code] =&gt; ''
)</pre>

<p>Here is an example <code>$mod</code> array for a WooCommerce product category term:</p>

<pre>Array (
    [id] =&gt; 890
    [name] =&gt; term
    [name_transl] =&gt; term
    [obj] =&gt; object WpssoTerm
    [wp_obj] =&gt; object WP_Term
    [query_vars] =&gt; Array ()
    [posts_args] =&gt; Array ()
    [paged] =&gt; false
    [paged_total] =&gt; false
    [is_404] =&gt; false
    [is_archive] =&gt; true
    [is_attachment] =&gt; false
    [is_comment] =&gt; false
    [is_date] =&gt; false
    [is_day] =&gt; false
    [is_feed] =&gt; false
    [is_home] =&gt; false
    [is_home_page] =&gt; false
    [is_home_posts] =&gt; false
    [is_month] =&gt; false
    [is_post] =&gt; false
    [is_post_type_archive] =&gt; false
    [is_public] =&gt; true
    [is_search] =&gt; false
    [is_term] =&gt; true
    [is_user] =&gt; false
    [is_year] =&gt; false
    [comment_author] =&gt; false
    [comment_author_name] =&gt; false
    [comment_author_url] =&gt; false
    [comment_paged] =&gt; false
    [comment_parent] =&gt; false
    [comment_rating] =&gt; false
    [comment_time] =&gt; false
    [use_post] =&gt; false
    [post_slug] =&gt; false
    [post_type] =&gt; false
    [post_type_label_plural] =&gt; false
    [post_type_label_single] =&gt; false
    [post_mime_type] =&gt; false
    [post_mime_group] =&gt; false
    [post_mime_subgroup] =&gt; false
    [post_status] =&gt; false
    [post_author] =&gt; false
    [post_coauthors] =&gt; Array ()
    [post_time] =&gt; false
    [post_timestamp] =&gt; false
    [post_modified_time] =&gt; false
    [post_modified_timestamp] =&gt; false
    [post_parent] =&gt; false
    [term_tax_id] =&gt; 761
    [tax_slug] =&gt; product_cat
    [tax_label_plural] =&gt; Product categories
    [tax_label_single] =&gt; Category
    [user_name] =&gt; ''
    [wpml_code] =&gt; ''
)</pre>


```
