Abhineet.in

unlearning the learnt

Menu
  • Home
  • About
  • CAT Preparation
Menu

Tag: Coding

Sending JSON with data Javascript Fetch

Posted on November 13, 2022April 5, 2023 by Abhineet Mittal

An important reminder to include following header while sending data in Javascript fetch() call in JSON format. Also, do not forget to use JSON.Stringify(). var data = { some_data: ABC}; headers: { ‘Content-Type’: ‘application/json’, }, body: JSON.stringify( data ), This is not needed if you are creating a form data object and appending data to…

Read more

Reolved failed upload in WordPress post edit filter

Posted on April 13, 2022April 5, 2023 by Abhineet Mittal

When adding an upload form to the post edit screen in WordPress admin, I found the upload to fail. The $_FILES array was empty.The reason was that by default, WordPress post edit form does not send files data. To fix that, we need to add enctype attribute to the form.Here is the code to do…

Read more

How to customize PHP error message in WordPress

Posted on April 11, 2022April 5, 2023 by Abhineet Mittal

WordPress displays a default error message when it encounters a PHP error- There has been a critical error on this website. Learn more about troubleshooting WordPress. Now this message is subtle, but still reveals 2 things- Your website has some error Your website is built on WordPress Now second point is usually fine unless you…

Read more

How to change custom post permalink in WordPress

Posted on March 22, 2022April 5, 2023 by Abhineet Mittal

I have struggled with this issue for years. I tried different ways but they always felt like hacks and gave inconsistent results most of the time. I also tried a popular plugin which broke my site. Whenever you add a custom post type in WordPress through code, there is no way to select a permalink…

Read more

WordPress: Missing canonical tags on archive pages

Posted on March 21, 2022April 5, 2023 by Abhineet Mittal

WordPress keeps surprising me even after more than a decade since I started using it. Today I came to know that WordPress only generates canonical tags for singular pages (posts & pages). WordPress does not add canonical tags to archive pages including author page, post type archives, taxonomy archives etc. So, how to add canonical…

Read more

404 pages getting redirected to home

Posted on March 19, 2022April 5, 2023 by Abhineet Mittal

Today, I wasted major part of my day trying to figure out why my subfolder based WordPress multisite install is redirecting all 404 errors to the site’s home page. The problem turned out to be the constant “NOBLOGREDIRECT” which I defined in wp-config.php file. This constant ensures that in a multisite install, if anyone tries…

Read more

Prevent Form Resubmission on Page Refresh

Posted on June 28, 2021April 5, 2023 by Abhineet Mittal

We face a common issue on many websites that whenever a form submits to the same page, and then we refresh the page, the form data is submitted again. Sometimes the browser asks for confirmation, sometimes it does not. It becomes really frustrating if it causes an operation to happen twice. To prevent this on…

Read more

Prevent Memory Leak in WordPress

Posted on May 10, 2021April 5, 2023 by Abhineet Mittal

Recently I faced an issue of memory leak in one of my WordPress projects. I was running a function that was reading post meta and user metadata of thousands of objects. I thought reading data from MySQL is cheap in terms of processing power and memory, but it turned out it was causing my function…

Read more

Fix Indentation Issue in Visual Studio Code

Posted on May 7, 2021April 5, 2023 by Abhineet Mittal

Easily fix the tab size issue in Visual Studio Code by making this simple tweak in settings.

Read more

Correct Way to Manage Title Tags in WordPress

Posted on May 6, 2021April 5, 2023 by Abhineet Mittal

Correct way to add or modify title tags in WordPress using the latest theme support feature and the filter hook to dynamically modify it on the fly.

Read more
How to count words in Unicode string using PHP?

How to count words in Unicode string using PHP

Posted on January 23, 2017April 5, 2023 by Abhineet Mittal

How to count words in Unicode string using PHP? This sounds too easy. After all, PHP has so many string manipulation functions. To count words, we can simply use str_word_count and we are good to go. But there is a problem. While this function works fine for English strings, developers find this function unpredictable as sometimes…

Read more

Categories

  • Business
  • CAT Preparation
  • Coding
  • Fiction
  • Finance
  • How-To-Life
  • Javascript
  • Life
  • Life at Infosys
  • Photoshop
  • Productivity
  • Publishing
  • Social Awareness
  • Startup
  • Technology
  • Uncategorized
  • Utilities
  • Visual Studio Code
  • Web Development
  • WordPress
  • Work Culture

Recent Posts

  • The Ultimate Guide to CAT Preparation: Tips and Tricks
  • Self-Publishing vs. Traditional Publishing: Which Is Right for You?
  • 7 Effective Strategies to Overcome Procrastination and Achieve Your Goals
  • How to detect English/ASCII string in PHP
  • The state of automobile dealerships in India

Recent Comments

  • Rohan George on Intermediate, Stream & Location: Luck by Chance
  • Ashika on Intermediate, Stream & Location: Luck by Chance
  • Steve on My first job, Infosys
  • SAKTHI on Finally, its Mysore…
  • Akash dhyani Akash on Training Begins…
© 2023 Abhineet.in | Powered by Minimalist Blog WordPress Theme