• Resolved dzsekicsen

    (@dzsekicsen)


    Hello!

    How can I change the URL: localhost/?advert_category%5B%5D=82

    To: localhost/?car-category%5B%5D=82

    And how can I change the multiple category search form in advert_list and adverts_add page to simple search category? I mean I want to select only one category, not multiple.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter dzsekicsen

    (@dzsekicsen)

    Ok , I did the url with change the “adverts_request( “advert_category” )” to “adverts_request( “car-category” )” in search-by-category.php and it’s works fine.

    But I still can’t figure out my second question.

    It’s possible to add custom css style to the category dropdown?

    Hi,

    changing corefiles is not an good option. For both questions you can get solutions with the following links.

    You can use the codesnippets from Greg:
    https://github.com/simpliko/wpadverts-snippets?files=1
    Coding knowledge useful

    Or you can have a look to my plugin 😀
    https://wordpress.org/plugins/addonsuite-for-wpadverts/
    All options managed from wordpress admin dashboard without coding.

    Best regards

    • This reply was modified 5 years, 1 month ago by WPExtend.
    Thread Starter dzsekicsen

    (@dzsekicsen)

    Hi,

    Thanks for your reply.

    Can you help me how can I use this snippet (https://github.com/simpliko/wpadverts-snippets/tree/master/dependant-taxonomy-dropdown) on the adverts_list form too? Because it’s works on the adverts_ad page but I want to use it on both page.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    the snippet you can install as explained here (https://github.com/simpliko/wpadverts-snippets at the bottom of the page.

    I understand that by simple category select you mean that you would like to have a normal <select> field which allows selecting only one category?

    If so then to do that for [adverts_add] you would need to add the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "customize_adverts_add" );
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "advert_category" ) {
            $form["field"][$key]["max_choices"] = 1;
            $form["field"][$key]["validator"][0]["params"]["max_choices"] = 1;
        }
      }
      return $form;
    }
    

    The search by category on the [adverts_list] i assume you are adding using the Search By Category snippet https://github.com/simpliko/wpadverts-snippets/blob/master/search-by-category/search-by-category.php if so then in the snippet code you will need to find line "max_choices" => 10, and change it to "max_choices" => 1,.

    Thread Starter dzsekicsen

    (@dzsekicsen)

    Thanks for your reply,

    I already tried that but if I using this way then the site covers the category and can’t see them if dropdown.

    But if I use this snippet: https://github.com/simpliko/wpadverts-snippets/tree/master/dependant-taxonomy-dropdown then all goods on the [adverts_add] page. But I don’t know how to add this dropdown style to the [adverts_list] page too.

    Can I do that?

    I have used custom advert category dropdown named Pet Breed in search field . When user select the terms of advert_category i.e dogs, puppyetc, those selected values should be displayed in my custom search page like You have searched Pet Breed = dog,puppy .How to do that?
    if (isset($_GET[‘advert_category’])) {

    $taxonomy = ‘advert_category’;

    $terms = get_terms($taxonomy);

    if ( $terms && !is_wp_error( $terms ) ) :

    foreach ( $terms as $term ) {
    print_r( $term );
    if($term-> term_id == $cat)
    echo “Pet Breed= “. $term->name;
    }

    endif;
    }
    Its not working. It shows only one terms .Please tell me how to do?

    • This reply was modified 5 years, 1 month ago by mhjsam1.
    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    from your description i have no idea what you are trying to do or even where are you using this code?

    Please explain what you would like to do in more details, a link to a page where you are using this code would be even better.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Category link & search question’ is closed to new replies.