Search for Resources and Solutions

set_replacer - adds shortcodes in the frontend themes

set_replacer is a function for the Frontend Midrub Themes which allows to replace the placeholders added in the content. 

The feature is similar to the shortcodes which you've seen in other CMS. I have no idea if someone has patent for shortcodes and for this reason i've invented the replacers which could replace the placeholders. This could be useful for ads or other scopes.

How a replacer works? In your content you could add one of these codes:

  •  {any_keyword}

  • {any_keyword}content here{|any_keyword}

  • {any_keyword id="any id"}

  • {any_keyword id="any id"}content here{|any_keyword}


In your Inc's files from your theme add once:


set_replacer('code', function ($args = array()) {

if ( isset($args['start']) ) {

return str_replace('{ code}', '', $args['content']);

} else if ( isset($args['end']) ) {

return str_replace('{| code}', '', $args['content']);

} else {

return $args['content'];

} });


  • code is the keyword which should be replaced with the content provided by the replacer.
  • $args contains the parameters provided based on the placeholder. $args['start'] is provided when the placeholder starts and end when the placeholder is {| code}.
  • if a placeholder has parameters you will receive them as keywords with values. Look in the video below,



Was this article helpful?