• Resolved sellyk

    (@sellyk)


    Hi,

    I would like to know how it is I can move the position of the contact buttons on an advert.

    E.g. On a single Ad page, I would like to move it to be just after the Price and before the advert-grid section (where it states the category, location etc)

    If you could help me with a snippet for this, that would be great.

    Thanks in Advance.

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

    (@gwin)

    Hi,
    without modifying the template files, right now it is only possible to move the contact box below the gallery or below the data grid.

    If you want to have it specifically after the price, then you would need to open a file wpadverts/templates/single.php, cut the line <?php do_action( "adverts_tpl_single_bottom", $post_id ) ?> and paste it somewhere on a line about 36, before

    
    <div class="adverts-grid adverts-grid-closed-top adverts-grid-with-icons adverts-single-grid-details">
    

    You can also consider creating a child template for single.php as explained here https://wpadverts.com/documentation/child-themes-and-templates/ so your changes will not be overwritten on WPAdverts update.

    Thread Starter sellyk

    (@sellyk)

    Hi,

    If i want to move the contact box below the gallery how do i do that without modifying the template files?

    Thread Starter sellyk

    (@sellyk)

    Hi,

    In addition to the above, i’ve tried the snippet you gave me, but it didn’t work.

    I moved it to line 36 and no changes reflected, despite even clearing the cache.

    I even tried to delete that line completely to see if it would make any change to the front-end, but none.

    That line of code you provided me doesn’t seem to affect anything on the front end.

    In fact when i opened the single.php file it was missing the ‘?>’ at the end (i have now added it)

    Kindly, what could I be doing wrong?

    If you could also provide me with the way to move it below the gallery without touching the files, that would be great.

    Thanks.

    Plugin Author Greg Winiarski

    (@gwin)

    1. if you are making changes in the wpadverts/templates/single.php file and the changes are not visible on-site than either:

    – the page is using some caching plugin or on server caching and you need to clear the cache to see any changes.

    – you are using a child-template file for the single.php and this file is loaded from some other location (see “Replacing Default Templates” here https://wpadverts.com/documentation/child-themes-and-templates/ for more details).

    2. to put the contact information after gallery add the code below in your theme functions.php file

    
    add_action( "init", function() {
        remove_all_actions( "adverts_tpl_single_bottom" );
        add_action('adverts_tpl_single_top', 'adverts_single_contact_information');
        //add_action('adverts_tpl_single_top', 'adext_contact_form');
    }, 1000 );
    

    The code as is will show the Contact Information Box, if you are using the contact form, then comment out the first add_action() line and commet the second one.

    Thread Starter sellyk

    (@sellyk)

    Hi,
    The documentation link you sent helped me figure out why the changes I was making weren’t reflecting. Thanks.

    Also, Thanks for the snippet that worked well too.

    I have one more question , that isn’t necessarily to do with the above:

    I know that one can set the default visibility to 0 to have the ads never expire, however, I would like to know if there is a snippet that would have all the previously uploaded ads also be changed to ‘never expire’.

    Thanks in advance!.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    there isn’t a snippet for that, but you can run the below query from phpMyAdmin it will remove _expiration_date from all Ads making them non-expiring.

    Before running this query it is best to do a full site backup in case something goes wrong.

    
    DELETE FROM <code>wp_postmeta</code> WHERE <code>meta_key</code> = '_expiration_date';
    

    Please note that if some other plugins or theme are using the ‘_expiration_date’ meta key then it will also be deleted.

    Thread Starter sellyk

    (@sellyk)

    Hello,

    If I run that Query, is there a way that I can reverse it in future?

    Like if i want the ads to start expiring again at some point.

    If there is a way to reverse, what query would I run at that time?

    • This reply was modified 5 years, 3 months ago by sellyk.
    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    there is no way to revert that query if you would like to be able to restore the expiration dates then you can run a different query

    
    UPDATE wp_postmeta SET meta_key = '__backup_expiration_date' WHERE meta_key = '_expiration_date';
    

    and then to restore the expiration dates run

    
    UPDATE wp_postmeta SET meta_key = '_expiration_date' WHERE meta_key = '__backup_expiration_date';
    

    Note that this will restore expiration dates but all the Ads will still have status set to ‘publish’, until a cron job will run which will expire them (by default WPAdverts does this every 5 minutes or so).

    Thread Starter sellyk

    (@sellyk)

    Hello,

    The second sql snippet you provided worked great. So now I can easily revert at any point.

    Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Move Contact Buttons’ is closed to new replies.