wpseo_replace_vars

Replace `%%variable_placeholders%%` with their real value based on the current requested page/post/cpt.

Description

(string) wpseo_replace_vars( (string) $string, (object) $args, (array) $omit = array() ); 

Returns (string)

Parameters (3)

0. $string (string)
The string to replace the variables in.
1. $args (object)
The object some of the replacement values might come from, could be a post, taxonomy or term.
2. $omit — Optional. (array) => array()
Variables that should not be replaced by this function.

Usage

  1. if ( !function_exists( 'wpseo_replace_vars' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-functions.php'; 
  3.  
  4. // the string to replace the variables in. 
  5. $string = ''; 
  6.  
  7. // the object some of the replacement values might come from, could be a post, taxonomy or term. 
  8. $args = null; 
  9.  
  10. // variables that should not be replaced by this function. 
  11. $omit = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wpseo_replace_vars($string, $args, $omit); 
  15.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-functions.php  
  1. functionwpseo_replace_vars $string, $args, $omit = array() ) { 
  2. $replacer = new WPSEO_Replace_Vars; 
  3.  
  4. return $replacer->replace( $string, $args, $omit );