The $mod variable is defined early in the WPSSO Core load process and is passed to most methods and filters. The name $mod is short for “module” and it defines essential array values for three WPSSO Core module types:
- post
- term
- user
An example $mod array for a post:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Array ( [id] => 2717 [name] => post [use_post] => false [is_post] => true [is_home] => false [is_home_page] => false [is_home_posts] => false [is_post_type_archive] => false [is_public] => true [post_slug] => the-post-slug [post_type] => post [post_status] => publish [post_author] => 1 [post_coauthors] => false [is_term] => false [tax_slug] => '' [is_user] => false [obj] => object WpssoPost ) |
An example to retrieve custom post meta:
1 2 3 4 5 6 |
if ( $mod['is_post'] ) { $value = get_post_meta( $mod['id'], 'example_meta_name', true ); } |
The ‘obj’ element can be used to call the module object methods.
Here’s an example to get a custom Open Graph description value (if one has been defined):
1 2 3 |
$og_desc = $mod['obj']->get_options( $mod['id'], 'og_desc' ); |