So I’m using Newspaper theme for WordPress and would like to change the ads using functions.php depending on the url inputed.

If there is ?ads=no appended to the url it won’t show ads at all.

If there is ?ads=x or ?ads=y appended to the url it will show ads from a specific partner (we will have many).

For example, the theme shows the header ad like this:

<div class="td-header-rec-wrap">
    $tds_header_ad_title = td_util::get_option('tds_header_title');

    // show the header ad spot
    echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'header', 'spot_title' => $tds_header_ad_title)); ?>


File location /parts/header/ads.php

And the class is this:

class td_global_blocks {
    private static $global_instances = array();
    private static $global_id_lazy_instances = array();

     * @param $block_instance
     * @deprecated Use add_id instead of it. It's maintained just for plugin compatibility
    static function add_instance($block_instance) {

     * @param $block_id string keeps a reference of the block for lazy instance
    static function add_lazy_shortcode($block_id) {
        self::$global_id_lazy_instances[] = $block_id;
        add_shortcode($block_id, array('td_global_blocks', 'proxy_function'));

    static function proxy_function($atts, $content, $tag) {
        return self::get_instance($tag)->render($atts, $content);

    static function get_instance($block_id) {
        if (isset(self::$global_instances[$block_id])) {
            return self::$global_instances[$block_id];
        } else if (in_array($block_id, self::$global_id_lazy_instances)) {
            $new_instance = new $block_id();
            self::$global_instances[$block_id] = $new_instance;
            return $new_instance;
        } else {
             * return a fake new instance of td_block - so that we have the render() method for decoupling - when the blocks are deleted :)  @todo wtf?
            return new td_block();

File location includes/wp_booster/td_global_blocks.php

I know it’s possible to override. Maybe using something like add_action() or add_filter(). I just don’t know how to do it.

Could you please help me out?

I appreciate your time. Thanks heaps 😉

Read more here: Child theme WordPress: Override custom options on functions.php according to urls params


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: