Support » Plugin: WPAdverts - Classifieds Plugin » Category Listing display options

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    currently to do that you would need to open file wpadverts/templates/list-item.php and add the additional fields there.

    For example if you have a custom field named game_type then you can display the custom field value with this code (on line about 18)

    
    <?php echo esc_html( get_post_meta( get_the_ID(), "game_type", true ) ) ?>
    

    Please note that the customizations you will make in list-item.php file will be overwritten on WPAdverts update, to avoid that you will need to create a child-template file for the list-item.php as explained here https://wpadverts.com/documentation/child-themes-and-templates/

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Thank works great.
    Say I wanted to do this for only one category
    i.e.

    <b>Manufacturer:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_71", true ) ) ?>
    </br>
    <b>Engine Hrs:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_Engine_hours", true ) ) ?>
    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Ideally, it would be great if the custom fields had a checkbox to show a custom field in the brief listing. What effort would this take to implement? In the meantime, the above question could be solved if we place it in an if category = planes then show the custom fields. Just not sure how to do that

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    What I am trying to do is get the category and if it is “aircraft_for_sale” show the custom fields . I am just not sure what to make the if statement
    Here is what I have

     <div style="padding-left:10px; font-size:14px;">
                <?php $advert_category = get_the_terms( $post_id, 'advert_category' ) ?>
                    <?php /*echo $advert_category*/ ?>
                <b>Location: </b>
                <?php echo esc_html( get_post_meta( get_the_ID(), "adverts_location", true ) ) ?>
    Plugin Author Greg Winiarski

    (@gwin)

    To show the custom fields for a specific category only you would need to use the below code

    
    <?php if( has_term( "aircraft_for_sale", "advert_category", get_the_ID() ): ?>
    Your custom fields code goes here ...
    <?php endif; ?>
    

    We are planning to allow displaying additional data on the [adverts_list] without custom coding it, but it will be available in the WPAdverts redesign which we are planning for the middle of next year, so i am afraid it will not be available soon.

    Dear Greg,
    I would like to disable email as required field as well as enable phone number field as required field in post ad form. I can remove email field as well as enable phone number field seperately pasting the codes you provided in functions.php. But when I try both, error occurs. How can I disable email field along with enabling phone number field?

    Thanks in advance.

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Hi Greg, unfortunately the following gives an error. Any clues what could be wrong?
    Dougall

    <?php if( has_term( “aircraft_for_sale”, “advert_category”, get_the_ID() ): ?>
    <b>Location: </b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “adverts_location”, true ) ) ?>
    </br>
    <b>Engine Make: </b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_engine_make”, true ) ) ?>
    </br>
    <b>Engine Hrs:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_Engine_hours”, true ) ) ?>
    </br>
    <b>Fuel Litres/hr:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_litres_per_hour”, true ) ) ?>
    </br>
    <b>Engine size:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_engine_size”, true ) ) ?>
    </br>
    <b>Prop Hours:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_prop_hours”, true ) ) ?>
    </br>
    <b>Frame TT:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_frame_tt”, true ) ) ?>
    </br>
    <b>Year:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_years”, true ) ) ?>
    </br>
    <b>Next Annual due date:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), “custom_field_due_date”, true ) ) ?>
    <?php endif; ?>

    Plugin Author Greg Winiarski

    (@gwin)

    @dougallwrennmaxwell there is one “)” missing on the first line which causes a parse error, please try this code instead

    
    <?php if( has_term( "aircraft_for_sale", "advert_category", get_the_ID() ) ): ?>
    <b>Location: </b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "adverts_location", true ) ) ?>
    </br>
    <b>Engine Make: </b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_engine_make", true ) ) ?>
    </br>
    <b>Engine Hrs:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_Engine_hours", true ) ) ?>
    </br>
    <b>Fuel Litres/hr:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_litres_per_hour", true ) ) ?>
    </br>
    <b>Engine size:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_engine_size", true ) ) ?>
    </br>
    <b>Prop Hours:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_prop_hours", true ) ) ?>
    </br>
    <b>Frame TT:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_frame_tt", true ) ) ?>
    </br>
    <b>Year:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_years", true ) ) ?>
    </br>
    <b>Next Annual due date:</b>
    <?php echo esc_html( get_post_meta( get_the_ID(), "custom_field_due_date", true ) ) ?>
    <?php endif; ?>
    

    @kowser73 you can add the code below to make the phone number required and the email optional, but i would highly recommend leaving the email as required since without the entered email users can expeirence some issues (for example if they check the “Account” checkbox the registration will fail without email address).

    
    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"] == "adverts_email" ) {
            $form["field"][$key]["is_required"] = false;
            unset( $form["field"][$key]["validator"][0] ); 
        }
        if( $field["name"] == "adverts_phone" ) {
            $form["field"][$key]["is_required"] = true;
            $form["field"][$key]["validator"][] = array( "name"=> "is_required" ); 
        }
      }
      return $form;
    }
    

    BTW. Please do not hijack the threads, if you have a question unrelated to a thread please start a new one, thanks.

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Hi Greg, Hopefully this is the last change
    When I have two different categories, the final payment option allows us to select either payment, ie for plane listing and parts listing.
    Is it possible to just show the payment for each category. ie. Plane listing $30 and parts listing $5 for when its a part? Just not both options when its either category
    http://www.aircraft4sale.com.au/payment.png

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i understand you would like to charge a different fee depending on a selected category? If so then this is possible with the Fee Per Category extension https://wpadverts.com/extensions/fee-per-category/

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Thanks for that I should have looked a little closer at what I purchased.
    I do have an issue though,
    I have two categories.
    Aircraft Parts $5
    Aircraft $30
    After I have entered the details of the aircraft I have added, down the bottom I get to select between Parts or aircraft and if I select part I only pay $5 for an aircraft listing. Is there any possible way to have only the cost for the relevant category showing?
    see screenshot at http://rain.dog/multiple.jpg

    Plugin Author Greg Winiarski

    (@gwin)

    Hmm actually when you select a category in the Category dropdown the Fee Per Category should reload the pricings and show only the ones that are applicable.

    Can you send me a link to a page where you have the [adverts_add] shortcode so i can take a look at it and maybe a screenshot from your FPC configuration so i can see if it is setup correctly?

    It would be best if you could send all that using the contact form at https://wpadverts.com/contact/ as discussing the extensions on the forum here is against the WP.org rules.

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    Hi Greg,
    I sent the details on your forum to have a look if you like.
    Let me know if you find anything
    My email is dougall at wrenmaxwell.com.au
    Dougall

    Thread Starter dougallwrennmaxwell

    (@dougallwrennmaxwell)

    I gave you the wrong access level. Now you are admin.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    thanks i have received the message and you should get a reply soon, but i cannot seem to find the link to your website with WPAdverts installed anywhere?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Category Listing display options’ is closed to new replies.