anurag.deshmukh
Forum Replies Created
-
Which WP version you are using ? Has it happened after any theme/Plugin or WP version up-gradation ?
Forum: Fixing WordPress
In reply to: Making attachment meta data requiredMedia section is provided by default by WP and seems it didn’t have filter to make those fields required. Making those changes in core files will be bad idea.
What we can do is that, whenever image is uploaded, based on image name, we can fill the meta data so that we can make sure they are not empty.
Paste below code in your theme’s functions.php file
add_action( 'add_attachment', 'set_image_meta_data_on_upload' ); function set_image_meta_data_on_upload( $post_ID ) { // Check if uploaded file is an image, else do nothing if ( wp_attachment_is_image( $post_ID ) ) { $image_title = get_post( $post_ID )->post_title; $image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ', $my_image_title ); $image_title = ucwords( strtolower( $my_image_title ) ); $image_meta = array( 'ID' => $post_ID, 'post_title' => $image_title, 'post_excerpt' => $image_title, 'post_content' => $image_title, ); update_post_meta( $post_ID, '_wp_attachment_image_alt', $image_title ); wp_update_post( $image_meta ); } }
If you wish, later you can change the meta data as per your choice.
Let me know if that works for you.
Forum: Fixing WordPress
In reply to: pagination pluginYou can go with below plugin.
Forum: Developing with WordPress
In reply to: Admin-ajax.php 400 errorYou need to replace wp_ajax_function_name with wp_ajax_AjaxVid and wp_ajax_nopriv_function_name with wp_ajax_nopriv_AjaxVid.
So your new changes would look like :add_action('wp_ajax_AjaxVid', 'AjaxVid'); add_action('wp_ajax_nopriv_AjaxVid', 'AjaxVid');
in js part, url you need to pass is :
url: script.ajaxurl,
Forum: Plugins
In reply to: [Gutenberg] Preview not generatingDon’t know what caused this, but issue got resolved.
I am able to see the preview now.Thanks.
Forum: Fixing WordPress
In reply to: How do I move title of my theme to the center of my header?You can place code for Navigation menu before Logo and then adjust the logo which I assume will be an image.
Forum: Fixing WordPress
In reply to: Captcha loading…Which plugin you have used for Captcha ?
Forum: Developing with WordPress
In reply to: Admin-ajax.php 400 error1. In order to use ajax with WordPress, you need to first use wp_enqueue_script() so javascript gets included on the page.
wp_enqueue_script( 'ajax-script', plugins_url( '/js/my_query.js', __FILE__ ), array('jquery') ); wp_localize_script( 'ajax-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
2. Then you need to use below 2 hooks in order to add functionality and when we need to fire for both non logged in and logged-in users.
add_action('wp_ajax_function_name', 'function_name'); add_action('wp_ajax_nopriv_function_name', 'function_name');
3.In your js file add code for calling ajax.
jQuery('.class_name').click(function(){ var str = { 'action': 'function_name', 'value1': 'value1 to pass', 'value2': 'value2 to pass', }; jQuery.ajax({ type: "POST", dataType: "html", url: ajax-script.ajaxurl, data: str, success: function(data){ // Code after ajax success }, error : function(jqXHR, textStatus, errorThrown) { $loader.html(jqXHR + " :: " + textStatus + " :: " + errorThrown); } }); });
4. Write your function in functions.php file.
function function_name() { // do stuffs whatever you wish to do in your function $html = 'ajax'; echo $html; // please make sure echo your output here wp_die(); // this is required to terminate immediately and return a proper response }
Hope this helps.
Forum: Fixing WordPress
In reply to: Confirmation required on email changeWhere is the user redirected when he/she clicks on personal link ? There might be any profile manageable page from where user can update the details.
Is there any plugin used for that or it’s WP default ?
If that has been any form, and on submitting of that form, email gets updated, we can apply code on form submission and can check if old email and new email is different, we can notify to admin.
Forum: Fixing WordPress
In reply to: Confirmation required on email changeYou can paste below code in your current theme’s functions.php file
1. If user changes email address from his/her profile function update_profile_email_adddress( $user_id, $old_user_data ) { $user = get_userdata( $user_id ); if($old_user_data->user_email != $user->user_email) { $admin_email = "[email protected]"; $msg = sprintf( __( 'Below user has updated their profile.' ) ) . "\r\n\r\n"; $msg .= sprintf( __( 'User Name: %s' ), $user->display_name ). "\r\n\r\n"; $msg .= sprintf( __( 'Previous Email: %s' ), $old_user_data->user_email ). "\r\n\r\n"; $msg .= sprintf( __( 'New Email: %s' ), $user->user_email ). "\r\n\r\n"; wp_mail( $admin_email, sprintf( __( '[Your Site Name] User Profile Update' ), get_option('blogname') ), $msg ); } } add_action( 'profile_update', 'update_profile_email_adddress', 10, 2 ); 2. Admin/website send confirmation email. || This will be similar when new user registers on your site if ( !function_exists('wp_new_user_notification') ) { function wp_new_user_notification( $user_id, $plaintext_pass = '' ) { $user = new WP_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); $message = sprintf(__('New user registration on your website. %s:'), get_option('blogname')) . "rnrn"; $message .= sprintf(__('Username: %s'), $user_login) . "rnrn"; $message .= sprintf(__('E-mail: %s'), $user_email) . "rn"; wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message); } }
Hope this helps.
Forum: Fixing WordPress
In reply to: Editing links in wp editorYou can run below queries in database.
UPDATE wp_options SET option_value = replace(option_value, ‘https://www.oldurl’, ‘https://www.newurl’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘https://www.oldurl’,’https://www.newurl’);
UPDATE wp_posts SET post_content = replace(post_content, ‘https://www.oldurl’, ‘https://www.newurl’);
UPDATE wp_postmeta SET meta_value = replace(meta_value,’https://www.oldurl’,’https://www.newurl’);
UPDATE wp_links SET link_url = replace(link_url, ‘https://www.oldurl’,’https://www.newurl’);
UPDATE wp_comments SET comment_content = replace(comment_content , ‘https://www.oldurl’,’https://www.newurl’);
UPDATE wp_posts SET post_content = replace(post_content, ‘https://www.oldurl’,’https://www.newurl’);
UPDATE wp_links SET link_image = replace(link_image, ‘https://www.oldurl’,’https://www.newurl’);
UPDATE wp_posts SET guid = replace(guid, ‘https://www.oldurl’,’https://www.newurl’);
Make sure to replace wp_ if any other table_prefix has been used.
Forum: Fixing WordPress
In reply to: All Pages are returning error 404So you have used redirection plugin. Also are you using any REST API’S manually ?
Can you please brief some more on this ?Forum: Fixing WordPress
In reply to: Changing footer colorI didn’t find ‘footer-group-section’ class name on site. You need to check for correct class name where you need to add css/change color.
Forum: Fixing WordPress
In reply to: – 2 in the urlDid you check with trash posts also ?
Forum: Fixing WordPress
In reply to: All Pages are returning error 404Did you checked with site permalinks ? To do so
> Login to admin >> Settings >> Permalinks> Select ‘Plain’ radio button once and then click on ‘Save Changes’ button.
> Check front page and other pages if they are working. If permalink issue is there, pages/posts should work.
> Again go to permalink settings and select ‘Post name’ option and click on ‘Save Changes’.
Once this updated, you should get below code in .htaccess file.# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Check for the pages/posts they should not give 404 error.