Nicolas Wuergler

Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • in reply to: Sort listings by price #494108

    Nicolas Wuergler
    Expired Member
    Post count: 7

    Well, for anyone out there that is interested in said functionality, this works with V2 🙂

    // fire the function every time a listing is published or edited
    add_action('geodir_after_save_listing','my_change_custom_field_on_save',10,2);
    
    // this is the function that will set the correct value in the my_custom_sort custom field
    function my_change_custom_field_on_save($post_id, $post_info){
    
    //Checks for package ID 1, the free price in our example
    if(isset($post_info['package_id']) && $post_info['package_id']=='1'){
    
    //set position number 3 in geodir_my_custom_sort for the free price
    geodir_save_post_meta($post_id, 'my_custom_sort','3');
    
    //Checks for package ID 4, the silver price in our example
    }elseif(isset($post_info['package_id']) && $post_info['package_id']=='4'){
    
    //set position number 2 in geodir_my_custom_sort for the silver price
    geodir_save_post_meta($post_id, 'my_custom_sort','2');
    
    //Checks for package ID 5, the gold price in our example
    }elseif(isset($post_info['package_id']) && $post_info['package_id']=='5'){
    
    //set position number 1 in geodir_my_custom_sort for the gold price
    geodir_save_post_meta($post_id, 'my_custom_sort','1');
    
    }
    
    }
    
    //this is the function to update all existing listings at once. It won’t do anything until we call it from within a template.
    function my_change_custom_field_on_save_existing() {
    
    global $wpdb;
    
    //set position 3 for free price on custom field geodir_my_custom_sort
    $wpdb->query("UPDATE 'wp_geodir_gd_place_detail' SET 'my_custom_sort'=3 WHERE 'package_id'=1");
    
    //set position 2 for bronze price on custom field geodir_my_custom_sort
    $wpdb->query("UPDATE 'wp_geodir_gd_place_detail' SET 'my_custom_sort'=2 WHERE 'package_id'=4");
    
    //set position 1 for silver price on custom field geodir_my_custom_sort
    $wpdb->query("UPDATE 'wp_geodir_gd_place_detail' SET 'my_custom_sort'=1 WHERE 'package_id'=5");
    
    }
    in reply to: Sort listings by price #493884

    Nicolas Wuergler
    Expired Member
    Post count: 7

    Hi Kor,

    Thank you. Please note, I do not want to set the default sort priority manually for each individual post. GeoDirectory published a function that achieves this automatically when a listing is published (see https://wpgeodirectory.com/how-to-sort-listings-by-price/ ) I have set up the field as described and can see the new field with all individual posts, however the script does not automatically fill the new custom field in those posts. With V2 this script needs to be changed in order to work and there is a support comment that the script will be updated to work with V2. But I cannot find the updated script. Can you please help?

    Thanks

    in reply to: Sort listings by price #493827

    Nicolas Wuergler
    Expired Member
    Post count: 7

    followed your tutorial and used your function as snippet. While I can see a my new custom field, the function does not insert anything in the new custom field. Used to be V1 code. What do I need to change to make it work with V2? Thank you.

    
    // fire the function every time a listing is published or edited
    add_action(‘geodir_after_save_listing’,’my_change_custom_field_on_save’,10,2);
    
    // this is the function that will set the correct value in the my_custom_sort custom field
    function my_change_custom_field_on_save($post_id, $post_info){
    
    //Checks for package ID 1, the free price in our example
    if(isset($post_info[‘package_id’]) && $post_info[‘package_id’]==’1′){
    
    //set position number 3 in geodir_my_custom_sort for the free price
    geodir_save_post_meta($post_id, ‘geodir_my_custom_sort’,’3′);
    
    //Checks for package ID 4, the silver price in our example
    }elseif(isset($post_info[‘package_id’]) && $post_info[‘package_id’]==’4′){
    
    //set position number 2 in geodir_my_custom_sort for the silver price
    geodir_save_post_meta($post_id, ‘geodir_my_custom_sort’,’2′);
    
    //Checks for package ID 5, the gold price in our example
    }elseif(isset($post_info[‘package_id’]) && $post_info[‘package_id’]==’5′){
    
    //set position number 1 in geodir_my_custom_sort for the gold price
    geodir_save_post_meta($post_id, ‘geodir_my_custom_sort’,’1′);
    
    }
    
    }
    in reply to: tab CPT twice #493649

    Nicolas Wuergler
    Expired Member
    Post count: 7

    Absolutely, now that’s embarrassing. There was a duplicate tab. I somehow assumed one has to insert the linked field nested below the tab for the content to show. But of course, the tab already is a field, and it already is displaying content. Solved. Thanks.

    in reply to: User role and category alignment #491756

    Nicolas Wuergler
    Expired Member
    Post count: 7

    Hello Alex,

    Thank you for flagging. Yes, I have Version 2.0.0.62 installed.

    The pricing manager extension allows me to choose which categories are to be displayed on the add-listing page. However, as a default logic, it would make sense that if such a choice results in only one category being displayed/offered no manual selection be necessary or even better one could set a default select manually (ideally even allowing for a dependency on package selection).

    Thanks for your support!

    in reply to: Warning message with new theme activation #489885

    Nicolas Wuergler
    Expired Member
    Post count: 7

    When I removed the error messages I got a blank page. So I figured it has something to do with a blank template in my theme. I manually set the page under GD – Design – Archive to a specific template and it works.

    in reply to: Warning message with new theme activation #489797

    Nicolas Wuergler
    Expired Member
    Post count: 7

    Thanks Alex,

    Well, I currently can’t set up a read only http://ftp... maybe you can quickly look at the below. The error concerns this section in template-loader.php of wp. Any ideas before I try setting up the ftp?:

    * Filters the path of the current template before including it.
    *
    * @since 3.0.0
    *
    * @param string $template The path of the template to include.
    */
    if ( $template = apply_filters( ‘template_include’, $template ) ) {
    include( $template );
    } elseif ( current_user_can( ‘switch_themes’ ) ) {
    $theme = wp_get_theme();
    if ( $theme->errors() ) {
    wp_die( $theme->errors() );
    }
    }
    return;
    endif;

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