Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the Post ID as an option for custom targeting. #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ All taxonomies that are associated with Ad Layers (category and post_tag by defa
Click "Add custom targeting" to choose one or more DFP custom targeting variables to add to the DFP request produced by this ad layer. The value can be:
- The term(s) associated with the page. This will only be populated on taxonomy archives or single posts. The taxonomies associated with Ad Layers are available for selection.
- The post type of the page. This will only be populated on post type archives or single posts.
- The post id of the post or page. This will only be populated on single posts and pages.
- The author. This will only be populated on author archives or single posts.
- Other. This can be any free-form text value and will be static anywhere the ad layer is displayed.

Expand Down
1 change: 1 addition & 0 deletions php/ad-servers/class-ad-layers-ad-server.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ private function get_custom_targeting_sources() {
// Add additional options
$options = array_merge( $options, array(
'post_type' => __( 'Post Type', 'ad-layers' ),
'post_id' => __( 'Post ID', 'ad-layers' ),
'author' => __( 'Author', 'ad-layers' ),
'other' => __( 'Other', 'ad-layers' ),
) );
Expand Down
5 changes: 5 additions & 0 deletions php/ad-servers/class-ad-layers-dfp.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ public function get_targeting_value( $key, $source, $values = null ) {
$targeting_value = $queried_object->name;
}
break;
case 'post_id':
if ( is_singular() ) {
$targeting_value = (string) get_the_ID();
}
break;
default:
if ( taxonomy_exists( $source ) ) {
if ( is_singular() ) {
Expand Down