The $mod
variable is defined early in the load process (in WpssoHead->show_head()
, which is hooked to the 'wp_head' action) and is passed to most WPSSO methods and filters.
$wpsso =& 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->page->get_mod( $use_post );
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 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, $mod[ 'obj' ]
would be false and other properties like $mod[ 'is_archive' ]
, $mod[ 'is_date' ]
, and $mod[ 'is_month' ]
would be true.
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()
method from those class objects.
$wpsso =& Wpsso::get_instance(); // Get information for comment ID 123. $mod = $wpsso->comment->get_mod( $comment_id = 123 ); // Get information for post ID 123. $mod = $wpsso->post->get_mod( $post_id = 123 ); // Get information for term ID 123. $mod = $wpsso->term->get_mod( $term_id = 123 ); // Get information for user ID 123. $mod = $wpsso->user->get_mod( $user_id = 123 );
Functions to get the $mod
array are also available:
// 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 );
Here is an example $mod
array for a post:
Array ( [id] => 123 [name] => post [name_transl] => post [obj] => object WpssoPost [wp_obj] => object WP_Post [query_vars] => Array () [posts_args] => Array () [paged] => false [paged_total] => 1 [is_404] => false [is_archive] => false [is_attachment] => false [is_comment] => false [is_date] => false [is_day] => false [is_home] => false [is_home_page] => false [is_home_posts] => false [is_month] => false [is_post] => true [is_post_type_archive] => false [is_public] => false [is_search] => false [is_term] => false [is_user] => false [is_year] => false [comment_author] => false [comment_author_name] => false [comment_author_url] => false [comment_paged] => false [comment_parent] => false [comment_rating] => false [comment_time] => false [use_post] => false [post_slug] => the-post-slug [post_type] => post [post_type_label_plural] => Posts [post_type_label_single] => Post [post_mime_type] => '' [post_mime_group] => '' [post_mime_subgroup] => '' [post_status] => publish [post_author] => 123 [post_coauthors] => Array () [post_time] => 2013-03-15T22:23:27+00:00 [post_timestamp] => 1363386207 [post_modified_time] => 2021-01-31T00:16:46+00:00 [post_modified_timestamp] => 1612052206 [post_parent] => false [tax_slug] => '' [tax_label_plural] => false [tax_label_single] => false [user_name] => '' [wpml_code] => '' )
Here is an example $mod
array for a WooCommerce product:
Array ( [id] => 4567 [name] => post [name_transl] => post [obj] => object WpssoPost [wp_obj] => object WP_Post [query_vars] => Array () [posts_args] => Array () [paged] => false [paged_total] => 1 [is_404] => false [is_archive] => false [is_attachment] => false [is_comment] => false [is_date] => false [is_day] => false [is_feed] => false [is_home] => false [is_home_page] => false [is_home_posts] => false [is_month] => false [is_post] => true [is_post_type_archive] => false [is_public] => true [is_search] => false [is_term] => false [is_user] => false [is_year] => false [comment_author] => false [comment_author_name] => false [comment_author_url] => false [comment_paged] => false [comment_parent] => false [comment_rating] => false [comment_time] => false [use_post] => false [post_slug] => hoodie [post_type] => product [post_type_label_plural] => Products [post_type_label_single] => Product [post_mime_type] => '' [post_mime_group] => false [post_mime_subgroup] => false [post_status] => publish [post_author] => 123 [post_coauthors] => Array () [post_time] => 2023-02-16T12:34:11+00:00 [post_timestamp] => 1676550851 [post_modified_time] => 2023-07-04T00:54:41+00:00 [post_modified_timestamp] => 1688432081 [post_parent] => false [term_tax_id] => false [tax_slug] => '' [tax_label_plural] => false [tax_label_single] => false [user_name] => '' [wpml_code] => '' )
Here is an example $mod
array for a WooCommerce product category term:
Array ( [id] => 890 [name] => term [name_transl] => term [obj] => object WpssoTerm [wp_obj] => object WP_Term [query_vars] => Array () [posts_args] => Array () [paged] => false [paged_total] => false [is_404] => false [is_archive] => true [is_attachment] => false [is_comment] => false [is_date] => false [is_day] => false [is_feed] => false [is_home] => false [is_home_page] => false [is_home_posts] => false [is_month] => false [is_post] => false [is_post_type_archive] => false [is_public] => true [is_search] => false [is_term] => true [is_user] => false [is_year] => false [comment_author] => false [comment_author_name] => false [comment_author_url] => false [comment_paged] => false [comment_parent] => false [comment_rating] => false [comment_time] => false [use_post] => false [post_slug] => false [post_type] => false [post_type_label_plural] => false [post_type_label_single] => false [post_mime_type] => false [post_mime_group] => false [post_mime_subgroup] => false [post_status] => false [post_author] => false [post_coauthors] => Array () [post_time] => false [post_timestamp] => false [post_modified_time] => false [post_modified_timestamp] => false [post_parent] => false [term_tax_id] => 761 [tax_slug] => product_cat [tax_label_plural] => Product categories [tax_label_single] => Category [user_name] => '' [wpml_code] => '' )