Set Default Category

This topic contains 5 replies, has 2 voices, and was last updated by  Paolo 8 years, 3 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #115129

    Wayne Harvey
    Expired Member
    Post count: 102

    Hi there,
    I’ve got only one Post Type and one Category. I’m trying to have the category selection done automatically and then hide the input field on the “Add Listing” page with CSS (I know how to do the CSS step).
    I’ve seen the following post (https://wpgeodirectory.com/support/topic/autofill-category/) but don’t know where to put it or how to modify it to suit my needs.
    Thanks
    Wayne

    #115186

    Paolo
    Site Admin
    Post count: 31206

    You can add that in GeoDirectory >> Desing >> Scripts >> Footer scripts.

    To edit it it depends on your settings. What is the catgeory ID of your only category? Is your CPT places?

    Do you have 1 or more price plans?

    With these answers we shoudl be able to provide the correct code.

    Let us know,

    Thanks

    #115241

    Wayne Harvey
    Expired Member
    Post count: 102

    Hi Paolo
    My CPT is indeed “places”. My only category ID is 9.
    I have 3 price plans with package ids of 1, 15, 16
    Thanks in advance.
    Wayne

    #115244

    Paolo
    Site Admin
    Post count: 31206

    For all of them the category will be the same?

    In that case the code would be :

    
    
    
    <script>
    
    jQuery(document).ready(function(){
        
        if(location.pathname == "/add-listing/")
        {
                jQuery('#gd_placecategory.chosen_select').val('9').change();
                setTimeout(function()
                {
                    jQuery('input[name = post_default_category][value = 9]').attr("checked", "checked");
                }, 2000);
      
        }
    
    });
    
    </script>

    It should work in both footer or header scripts.

    Let us know,

    Thanks

    #115256

    Wayne Harvey
    Expired Member
    Post count: 102

    Hello Paolo,
    Perfect! Worked exactly as I had hoped.
    Thanks very much,
    Wayne

    #115291

    Paolo
    Site Admin
    Post count: 31206

    You are welcome 🙂

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

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

Open Support Ticket