Next.js extends the native fetch Web API to allow you to configure the caching and revalidating behavior for each fetch request on the server. React extends fetch to automatically memoize fetch requests while rendering a React component tree. You can use fetch with async/await in Server Components, in Route Handlers, and in Server Actions. async function getData() { const res = await fetch(‘https://api.example.com/…’) // The return value is *not*… Continue reading Fetching Data on the Server with fetch
Tag: Wordpress
Dynamic Routes in Next JS
This is about how to assign the pages dynamically from each API Creating a static page for calling the single landing page This is an example of the folder structure for the dynamic pages <Link key={index} href={`/case-study/${category.slug}`}> <div> <p className=’jjrewamp-casestudylistpage-secondsection-first-filter-list-category-1′>{category.name}</p> </div> </Link> This is call to the casestudy page inner page <Link href={`/case-study/${category_slug}/${caseStudy.post_name}`}><h3 className=”jjrewamp-casestudylistpage-secondsection-categorysection-title-h3″>{caseStudy.post_title}</h3></Link> here… Continue reading Dynamic Routes in Next JS
how to optimize the code for Minimizing the main thread work of website(WordPress)
Caching: Implement a caching mechanism to store static or less frequently changing content. Popular caching plugins like W3 Total Cache or WP Super Cache can help with this. Lazy Loading: Implement lazy loading for images and other non-critical resources. This ensures that resources are loaded only when they are needed, reducing the initial page load… Continue reading how to optimize the code for Minimizing the main thread work of website(WordPress)
Stop runinng unwanted actions on WooCommerce
Add the following code to the functions.php to stop the action scheduler on the website. function yourprefix_disable_action_scheduler() { if ( class_exists( ‘ActionScheduler’ ) ) { remove_action( ‘action_scheduler_run_queue’, array( ActionScheduler::runner(), ‘run’ ) ); } } add_action( ‘init’, ‘yourprefix_disable_action_scheduler’, 10 ); Now this will disable the running status of all events on the woocoommerce. This may be… Continue reading Stop runinng unwanted actions on WooCommerce
Create a custom inside a product Admin Page to create a editor field
// Add Feature overview meta field to product admin page function add_feature_description_meta_field() { global $post; // Get the existing value $feature_description = get_post_meta($post->ID, ‘feature_description’, true); // Output the field echo ‘<div class=”options_group”>’; echo ‘<p class=”form-field”> <bold><label for=”sub_description”>’ . esc_html__(‘Feature Description’, ‘woocommerce’) . ‘</label></bold> </p>’; wp_editor( $feature_description, ‘feature_description’, array( ‘textarea_name’ => ‘feature_description’, ‘label’ => __(‘Sub Description’, ‘woo… Continue reading Create a custom inside a product Admin Page to create a editor field
To Overide the WooCommerce Templates
add_theme_support( ‘woocommerce’ ); need to Add the following to functions.php After adding this we can override the WooCommerce templates like Archieve-product.php Taxnomy-product_cat.php Single-product.php Files for the Category main page which includes the main categories and the next file includes the subcategory category and Product page with the category is listed in the Taxnomy-product_cat.php file And… Continue reading To Overide the WooCommerce Templates
Plugin for creating an submenu in wordpress
Insert the below code as a plugin in WordPress. code: <?php /* Plugin Name: Custom Department Plugin Description: Adds a custom menu for departments. Version: 1.0 Author: Mukil Mukesh M K */ function custom_department_menu() { add_menu_page( ‘Departments’, ‘Departments’, ‘manage_options’, … Continue reading Plugin for creating an submenu in wordpress
How to create a new field in the WordPress user section?
Example: Creating a new field named Skills Step 1: Write the below-given code in function.php in the current theme. function wk_custom_user_profile_skills_fields( $user ) { ?> <h3 class=”heading”>Skills</h3> <table class=”form-table”> <tr> <th><label for=”department”>Skills</label></th> <td> <textarea name=”skills” id=”skills” class=”regular-text”><?php echo esc_textarea( get_user_meta( $user->ID, ‘skills’, true ) ); ?></textarea> </td> </tr> </table> <?php } add_action( ‘show_user_profile’, ‘wk_custom_user_profile_skills_fields’ );… Continue reading How to create a new field in the WordPress user section?
New Gutenberg Editor in WordPress
The Gutenberg Editor is a block-based editor introduced in WordPress 5.0. It’s designed to revolutionize the editing experience by using a content structure based on blocks. Each element of content, such as paragraphs, headings, images, videos, and widgets, is treated as an individual block. Users can manipulate and arrange these blocks more intuitively, allowing for… Continue reading New Gutenberg Editor in WordPress
Set character limit in WordPress ACF texts
Sometimes, you might one to limit the character of text that user input in the text or text area field to prevent user input from breaking the design of the website. This great feature in included in the ACF plugin. What you have to do is to get into the ACF field and select the… Continue reading Set character limit in WordPress ACF texts