Jagdish Sarma | Reputations

Asked a question
WPDB check if table exist

[apcode language="php"] global $wpdb; $table = $wpdb->prefix . "byline_data_nw"; if($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {         echo 'Table...

2 days ago2
Asked a question
jQuery disable input text selection

[apcode language="jscript"] var inp = document.getElementById('input_10_6');  inp.addEventListener('select', function() {     this.selectionStart = this.selectionEnd; }, false);...

7 days ago2
Asked a question
WordPress 404 email alerts if query string matched

Add below script in 404.php file [apcode language="php"] // site info $blog = get_bloginfo('name'); $site = get_bloginfo('url') . '/'; $email = get_bloginfo('admin_email');...

March 9, 20232
Asked a question
WPDB replace specific url from post content

[apcode language="php"] $child_url = 'https://c2code.jagdish.info/'; $postid = trim(123);  if(!empty($vcontent_post_content)){           $content = apply_filters('the_content',...

March 7, 20232
Asked a question
WPDB SQL Query to fing tags which have minimum 10 posts

[apcode language="php"] $per_page = 500; if(!empty($_GET['per_page'])) {  $per_page =$_GET['per_page']; } //$offset = $per_page * ($currentPage - 1) ; $offset =0; if(!empty($_GET['offset'])){...

March 7, 20232
Asked a question
htaccess redirect whole domain

[apcode language="bash"] RewriteCond %{HTTP_HOST} ^wordpress.cloudwaysapps.com [NC,OR]  RewriteCond %{HTTP_HOST} ^www.wordpress.cloudwaysapps.com [NC]  RewriteRule ^(.*)$ https://www.newwebsie.com/ [L,R=301,NC]...

February 27, 20232
Asked a question
WP Job Manager get job type from job id

[apcode language="php"] <?php echo strip_tags(get_the_term_list( $entries_form->job_id, 'job_listing_type', '', ' / ' )); ?> [/apcode]

February 20, 20232
Asked a question
WordPress Retrieve Attachment ID from Image URL

Get the attachment ID from the file URL [apcode language="php"] // retrieves the attachment ID from the file URL function c2_get_image_id($image_url) {  global $wpdb;  $attachment = $wpdb->get_col($wpdb->prepare("SELECT...

February 17, 20232
Asked a question
How to set featured image programmatically from url?

[apcode language="php"] // Add Featured Image to Post $image_url = 'http://s.wordpress.org/style/images/wp-header-logo.png'; // Define the image URL here $image_name = 'wp-header-logo.png';...

February 17, 20232
Asked a question
Wordpress database custom query count posts by taxonomy

[apcode language="php"] global $wpdb;  $SQLquery = "     SELECT $wpdb->posts.ID FROM $wpdb->posts     LEFT JOIN $wpdb->term_relationships     ON ( $wpdb->posts.ID = $wpdb->term_relationships.object_id...

February 9, 20232
Asked a question
Change PHP version using .htaccess file code

[apcode language="bash"] # Use PHP74 as default AddHandler application/x-httpd-php74 .php <IfModule mod_suphp.c>     suPHP_ConfigPath /opt/php74/lib </IfModule> [/apcode]

February 9, 20232
Asked a question
WordPress set email address and sender email function

[apcode language="php"] // Function to change email address function wpb_sender_email( $original_email_address ) {     return 'thinds@workstaffusa.com'; }   // Function to change sender...

February 4, 20232
Asked a question
Stop video play after popup close

[apcode language="jscript"] jQuery(document).on('click', 'button.mfp-close', function() { jQuery('.popup-commen video').get(0).pause(); }); [/apcode]

February 3, 20232
Asked a question
Scroll margin top - Scroll Offset Css

[apcode language="css"] * {   scroll-margin-top: 100px; } [/apcode]

January 23, 20232
Asked a question
WordPress Repeater custom fields without plugin

[apcode language="php"] /********Add Crux/emotions field*******/ add_action('admin_init', 'c2_repet_add_meta_boxes', 2); function c2_repet_add_meta_boxes() {     add_meta_box( 'c2-repet-group',...

January 10, 20232
Asked a question
Security policy HTML meta tag

[apcode language="xml"] <meta http-equiv="Content-Security-Policy" content="default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src...

December 23, 20222
Asked a question
PHP Asia Timezone with add one minute

[apcode language="php"] date_default_timezone_set('Asia/Kolkata'); $minutes_to_add = 1; $time_up = new DateTime('2022-12-20 09:31:00'); $time_up->add(new DateInterval('PT'...

December 20, 20222
Asked a question
WP Json Ajax with data parse

Script: run only if field value not exist [apcode language="php"] get_loc = jQuery('#autcomplete-location').val();     if(get_loc=='' && '<?php echo $_GET["action"]?>'...

December 16, 20222
Asked a question
SQL WordPress create category

[apcode language="sql"] INSERT INTO `wp_terms` (`name`, `slug`, `term_group`) VALUES ('Videos', 'videos', '0');  INSERT INTO `wp_term_taxonomy` (`term_id`, `taxonomy`, `description`,...

December 9, 20222
Asked a question
Replace multiple dashes with one dash PHP

[apcode language="php"] $str = preg_replace('/-+/', '-', $new_url); [/apcode]

December 7, 20222
Load More