Pro sites Advertising Addon

Is it possible to use other location than "Before content" and the other 3 options ? for example to make the ads appear above the menu using an action hook.

  • Adam Czajczyk

    Hi Jose

    I hope you're well today and thank you for your question!

    The ads module of Pro Sites is using "the_content" filter to output ads so they can be added before or after it and with some additional code it might even be possible - though it would require parsing content which isn't the best idea, to be honest - to inject them inside but currently there's no way to put them anywhere else.

    Using any other hook would require changes in plugin's core files. We don't recommend it but if you can accept the risk you can try a change. Please note: any changes made can lead to unexpected issues and they'd also have to be re-applied to the site upon any update to the plugin.

    That said, if you look into the plugin's code, then in the file

    /wp-content/pro-sites/pro-sites-files/modules/ads.php

    you will find this code around line 30:

    add_filter( 'the_content', array( &$this, 'advertising_output' ) );

    You can try replacing "the_content" with the name of some other filter that you'd like to use. It has to be filter though and you would most likely also need to comment out this code in the same file around line 195:

    if (!in_the_loop () || !is_main_query ()) {
    			return $content;
    	    }

    Please note: this might take some experimenting to make it work and there might be some other adjustments that would have to be made.

    Another option - but that would also require custom coding - would be to actually output ads using a built-in options, without making changes to the plugin and then use JS/jQuery to "cut off" the advert block from page and inject it in the other place. That's doable but, again, it needs a custom developed code.

    If you need this to be coded for you, you might consider posting a job request at Codeable.io where you can find a professional developer who would be able to do this for you. You can also grab a discount for the service from our Partners page here:

    https://premium.wpmudev.org/partners

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.