Hello Sirs,
sorry to bother again: I really like the Idea of your Ad-System in general and in special the Content Ads! Ads are very important for refinancing a website! So, this is a great feature!
Of course not every suggestion must make common sense: But I would really think it would make much sense to improve „usability/functionality“ of your Theme, if you implemented a Filter for your Content Ads System.
Problem:
The „Content Ads“ is a great feature! But having Ads inside the Content can also be:
1.) very distrcting for users (=> so you want for shure some pages, WITHOUT any Content Ads!!)
2.) you might have to adjust the ad to the content. For example you want to filter for specific words in the content and then show different ads. Or show no ads at all. Or target the Ad to the advertiser. (For example like content about death and you do not want to put ads at all into this context.)
3.) For a lot of Custom Content Types showing ads might not make sense at all: (for example a custom content type „Jobs-Offer“, that should not be cluttered with ads).
=> But currently you can only disable the Content Ads in general but not on a more finer level… This is very sad, as I really llike the feature but I can only completely disable it.
Solution:
The most easiest solutoin is (though there are other solutions more complicated, even options that might be added to your Admin-Panel) just simply having a filter Hook, that allows a developer to hook into and manipulte the ads (do not show ads at all or alter the AdCode. This is ONE line of code, but improvies your theme by a magnitude! Would be kind if you comment, what you thinkg about this idea!
Benefits (you can use for marketing)
-More Developer friendly
-Helps Newspaper become a real plattform, as it can easyly be extended
-Can really make the Ads System in general much much much better (one can implement filters, intelligent ad logic and so on)
…
Add this one line
$ad_array = apply_filters( 'td_ads_ad_array', $ad_array ,$atts);
Into td_ad_box.php:
Note:
This can of course be improved. I have not looked that much into your code… the above is the minimum to fulfill basic needs)
But with this one line I was able to change the working of your ad system in a lot of ways! This is of course just intended ad proposal, please change/improve it to your liking (I do not know your coding/naming standards …Its just the way I use it currently)
Example Copied from your source, with the code added:
/**
* renders the ads
* @param $atts
* @return string
*/
function render( $atts ) {
extract(shortcode_atts(
array(
'spot_id' => '', //header / sidebar etc
'align' => '', //align left or right in inline content
), $atts));
if (empty($spot_id)) {
return;
}
$ad_array = td_util::get_td_ads($spot_id);
//ADDED FILTER!!!
$ad_array = apply_filters( 'td_ads_ad_array', $ad_array ,$atts);
// return if the ad for a specific spot id is empty
if (empty($ad_array[$spot_id]) or empty($ad_array[$spot_id]['ad_code'])) {
return;
}
$buffy = '';
if (!empty($ad_array[$spot_id]['current_ad_type'])) {
switch ($ad_array[$spot_id]['current_ad_type']) {
case 'other':
//render the normal ads
$buffy .= $this->render_ads($ad_array[$spot_id], $atts);
break;
case 'google':
//render the magic google ads :)
$buffy .= $this->render_google_ads($ad_array[$spot_id], $atts);
break;
}
}
//print_r($ad_array);
return $buffy;
}
Hi,
You can also achieve this using the “Advanced Custom Fields” plugin. Here is an implementation, take a look on the entire tread: https://forum.tagdiv.com/topic/function-to-hide-ads-and-function-to-show-author/#post-9187
Thanks again for your suggestion, we also plan to improve the ads system in the future so I have added this on our feature requests list and we will consider it.
Thanks
Hello Lucian,
thanks great!
(Just a Node. The Link you provided is interesting. This is a great additional feature (I have not thought about) but it is no substitute for my solution. As with my solution You simple write once the logic and then the ad system works on its own withouth any further work required. Where as in the link, you have to setup the “Show No Ads Flag” for every post, which is a huge time wast. If you plan to improve the ad System Both are required. One to individually Flag Posts/Pages (and CPTs!!!) manually in the Admin. And you also need a logic to filter Ads based in PHP Logik (based on Keywords and stuff => which requires a filter)… Furthermore if you plan to improve the ad system: Categories and CPTs are a must selection Criteria to Show/Notshow Ads.
thanks