Targeting Specific Sub-categories per CPT with Widget Logic

This topic contains 4 replies, has 4 voices, and was last updated by  Alex Rollin 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #464483

    David
    Expired Member
    Post count: 43

    Hopefully, somebody can assist me. I am trying to target specific categories of certain CPT’s with Amazon ads. For example, I have an automotive section on the site with other sub-categories :

    /automotive/GPS software
    /automotive/telematics software
    /automotive/self-driving cars

    Im using this bit of code in widget logic:

    geodir_get_current_posttype()==’gd_automotive’

    Which works well for some widget use case, and the whole category…

    Does anybody know what code would target just the specific sub-categories with widget logic?

    Thanks.

    #464511

    Paolo
    Site Admin
    Post count: 31206

    HI David,

    a developer will answer your question as soon as possible.

    Thanks for your patience

    #464592

    Kiran
    Moderator
    Post count: 7069

    Hello David,

    Use following logic to do stuff on specific category.
    CHANGE 57 to YOUR CATEGORY ID.

    
    
    global $gd_post;
    if ( ( geodir_is_page( 'listing' ) && is_tax() ) && ! empty( $gd_post ) && ! empty( $gd_post->default_category ) && (int) $gd_post->default_category == 57 ) {
    	// Do stuff
    }

    Kiran

    #464599

    David
    Expired Member
    Post count: 43

    Thanks, Kiran, will give this a shot!

    #464620

    Alex Rollin
    Moderator
    Post count: 27815

    See also the WP conditional tags
    https://codex.wordpress.org/Conditional_Tags

    There are other options there for categories etc.

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount