INN / doubleclick-for-wp

WordPress plugin for serving Google Ad Manager ads
https://wordpress.org/plugins/doubleclick-for-wp/
GNU General Public License v2.0
25 stars 11 forks source link

Year-old issue from WordPress.org #24

Closed benlk closed 7 years ago

benlk commented 7 years ago

https://wordpress.org/support/topic/categories-tags-bug-and-solution?replies=1#post-7127312

Great idea for a plugin!

Unfortunately there's a bug with the targeting but I managed to find a solution. Currently the script executes in the footer and tries to obtain the categories using get_the_category() and tags using get_the_tags() but because the footer is outside The Loop, these just return a subset of all categories and tags.

The fix is simple, for categories (around line 230) and tags (around line 247) in dfw-init simply access the wp_query and insert the ID as a parameter. The code should look something like:

global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); $cats = get_the_category($current_page_id); // Existing line with param added ... global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); $tags = get_the_tags($current_page_id); // Existing line with param added I hope you keep working on this plugin because it's a great idea and otherwise DFP is a headache to implement in WordPress without creating a Custom Theme or Child Theme.

  • [x] is this still a problem?
  • [ ] reply to thread
aschweigert commented 7 years ago

yes, it's a problem that does need to be fixed (that solution seems ok to me)