Sarthak Nagoshe
Forum Replies Created
-
I can see that you have applied 160px of padding to the entire page through elementor.
Removing that might help.Forum: Developing with WordPress
In reply to: button for resetting all the custom meta fieldsHey, I spend a good time to write a code for your requirement.
Step 1: Add JavaScript
Add the following JavaScript to your admin area. You can enqueue it using
admin_enqueue_scripts
.jQuery(document).ready(function($) { $('#target').on('click', function() { if (confirm("Do you really want to delete prices?")) { $.ajax({ url: ajaxurl, // WordPress AJAX URL type: 'POST', data: { action: 'reset_price_fields', // Custom action to be processed in PHP author_id: $(this).data('author-id') // Pass the author ID }, success: function(response) { alert(response.message); // Show success message }, error: function() { alert('Error resetting prices.'); // Show error message } }); } }); });
Step 2: Add PHP Function
Add this function to your theme’s
functions.php
file or a custom plugin.add_action('wp_ajax_reset_price_fields', 'reset_price_fields'); function reset_price_fields() { // Check for the required parameter if (!isset($_POST['author_id'])) { wp_send_json_error(['message' => 'No author ID provided.']); exit; } $author_id = intval($_POST['author_id']); $args = [ 'post_type' => 'apartment', // Change this to your custom post type 'author' => $author_id, 'posts_per_page' => -1 // Get all posts ]; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); // Get current custom fields $custom_fields = get_post_meta($post_id); // Prepare an array of custom fields to reset $fields_to_reset = ['price_field_1', 'price_field_2']; // Replace with your custom field keys foreach ($fields_to_reset as $field) { if (array_key_exists($field, $custom_fields)) { // Delete the specific custom field delete_post_meta($post_id, $field); } } } wp_send_json_success(['message' => 'Prices have been reset successfully.']); } else { wp_send_json_error(['message' => 'No posts found for this author.']); } wp_reset_postdata(); exit; }
Step 3: HTML
Make sure to include the
data-author-id
attribute in your button to pass the author’s ID.<button type="button" id="target" data-author-id="<?php echo get_current_user_id(); ?>">Cancella prezzi</button>
Let me know if this works for you & if requires any further modification.
Fix 1 :- Look for the
siteurl
andhome
entries and ensure they are both set tohttps://yourdomain.com
.Fix 2:- If you have access to your hosting control panel (like cPanel), you can edit the
wp-config.php
file directly from there.
Add the following lines to force your site to use HTTP:define('WP_HOME', 'https://yourdomain.com'); define('WP_SITEURL', 'https://yourdomain.com');
Forum: Everything else WordPress
In reply to: Trouble naming my plugin!some name ideas that avoid the term “plugin” while still conveying the purpose of your tool:
- Module Inspector
- Compatibility Guardian
- WordPress Watchdog
- Update Tracker
- Dependency Tracker
So, in this case you have 2 options:-
Option 1: Update the Site URL in
wp-config.php
- Open your site’s
wp-config.php
file using a text editor. - Add these lines right above the line that says
/* That's all, stop editing! Happy publishing. */
define('WP_HOME','https://your-local-site-url'); define('WP_SITEURL','https://your-local-site-url');
Replaceyour-local-site-url
with the correct local address (e.g.,https://yoursite.local
). - Save the file and try to access your site again.
Option 2: Change the URL in the Local Database
- Open Local and go to your site.
- Go to the Database tab and open Adminer or phpMyAdmin.
- Find the
wp_options
table (or{your_prefix}_options
if you use a custom prefix). - Look for the
siteurl
andhome
rows, and change them back tohttps://your-local-site-url
. - Save the changes and reload the site.
Forum: Developing with WordPress
In reply to: Maintenance mode with existing pageIf you want to turn on maintenance mode and redirect non-logged-in users to a specific page without using code, here’s a simple way to do it with WordPress features and plugins: Steps:
- Set your front page:
You’ve already set the specific page you want as your “Front Page.” This will be the main page visitors see, so this step is done. - Redirect other pages for non-logged-in users:
You can use a plugin that redirects users based on whether they are logged in or not.
Using a Redirection Plugin (like the Redirection plugin):
- Install and activate the plugin:
- Go to
Plugins > Add New
in your WordPress dashboard. - Search for Redirection and install it.
- Activate the plugin.
- Set up the redirection rules:
- Go to
Tools > Redirection
. - Click Add New.
- Set the source URL as
/(.*)
to catch all pages. - Set the target URL as your front page (e.g.,
https://yoursite.com/front-page/
). - In the Conditions section, set it to redirect only if the user is not logged in.
This rule will make sure non-logged-in users are sent to your front page.
- Check your headers and footers:
Since your page is built with Elementor and already includes the right header/footer, there’s no extra work needed to keep the design.
The result:
- Logged-in users/admins: They can still access all other pages.
- Non-logged-in visitors: They’ll be automatically redirected to your front page and see the page with your chosen design.
This method is easy to use and doesn’t require coding while keeping your layout and design intact.
Forum: Developing with WordPress
In reply to: How do I remove this empty space please?I can see that you have added a slider which seems to be empty thus producing empty space