Skip to main content

Posts

WP: 7. Control Tab on frontend with ACF[Solved]

    Today I ran into a problem, I needed to implement tabs on the front end with ACF dynamically and found this solution. And nonetheless, It's better to fix the thing with some bunch of code rather than uploading one more bulky plugin on your website that will end up making your site heavy. Just follow the steps below and avoid heading up into any malicious or bulky plugin for this particular problem from now on forever. Step 1: Execute loop first for tab navigation <?php $i=1; while(have_rows('data')) : the_row(); ?>   <button class="nav-item nav-link <?php if($i==1){echo "active";}?>" data-bs-toggle="tab" data-bs-target="#tab <?php echo $i;$i++;?> "> <h3 class="s-floorplan__tabs__title"><?php the_sub_field('tab_title'); ?></h3> <p class="s-floorplan__tabs__text"><?php the_sub_field('tab_sub_title'); ?></p>   </button> <?php ...

WP: 6. Related post loop by excluding the current post in single.php

   Today I ran into a problem, I need to implement a related post on the blog detail page and found this solution. And nonetheless, It's better to fix the thing with some bunch of code rather than uploading one more bulky plugin on your website that will end up making your site heavy. Just follow the steps below and avoid heading up into any malicious or bulky plugin for this particular problem from now on forever. Step 1: Get the id of current post in starting of single.php like following <?php $do_not_duplicate = $post->ID; ?> Step 1: Now in your related post query add the following <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'post__not_in'   => array( $do_not_duplicate ), 'order' => 'ASC', ); $related_query = new WP_Query($args);               while ( $related_query->have_posts() ): $related_query->the_post(); ?> Now Cheers !😊

WP: 5. Guide to Implement Next Previous Post Navigation in WP

  Today I ran into a problem, I need to implement to post previous and next navigation and found this solution. And nonetheless, It's better to fix the thing with some bunch of code rather than uploading one more bulky plugin on your website that will end up making your site heavy. Just follow the steps below and avoid heading up into any malicious or bulky plugin for this particular problem from now on forever. Step 1: Go ahead and paste the following code in your active theme's single.php //To return the URL of the previous page, use the following php code: $prev = get_permalink(get_adjacent_post(false,'',false)); //To return the URL of the next page, use the following php code: $next = get_permalink(get_adjacent_post(false,'',true)); //To use them, simply echo the variables $prev and $next where you need them. <a href="<?php echo $prev; ?>">Previous Post</a> and the  <a href="<?php echo $next; ?>">Next Post...

Brought up your Website's Google Page Speed upto 90+

 Hi Guys, If you are running or developing a website you may encounter low Google page speed, So let's dig deeper into the technical guide of Google Page Speed Insights to ensure a good score. Google defines page speed in two ways: How long it takes to display content above the fold. How long it takes a browser to fully render the page. The tool has two main things: Field Data,” or the performance data Second, it measures your page performance via the Lighthouse API. This is called “Lab Data” Field Data  or  Core  Web Vitals : First Contentful Paint (FCP): The time it takes for the first text or image asset to load. Largest Contentful Paint (LCP): The time it takes for the largest text or image asset to load. First Input Delay (FID): The time it takes for the browser to respond to the user’s first interaction. Cumulative Layout Shift (CLS): This measures any movement of the page in the viewport. Lab Data  : Speed Index:  The time it takes for the conten...

Error: Ensure text remains visible during webfont load [Resolved]

 Hi Guys, If you are running or developing a website you may encounter this error on Google page speed or GtMetrix, We should consider the following approach to get rid of this error. Suggestion 1: Load the fonts from your server, Even if you are using google fonts you should download and host it on your server.   Suggestion 2:  Use the font-display: swap CSS property while implementing custom fonts, this means the system default fonts will be loaded first and then the custom font is visible, hence text will remain visible.

C++: 9. File Handling

Files are used to store data in a storage device permanently. File handling provides a mechanism to store the output of a program in a file and perform various operations on it. Example of opening/creating a file    #include<iostream> #include<fstream> using namespace std; int main() { fstream new_file; new_file.open("new_file",ios::out); if(!new_file) { cout<<"File creation failed"; } else { cout<<"New file created"; new_file.close(); // Step 4: Closing file } return 0; } Writing to a File #include <iostream> #include <fstream> using namespace std; int main() { fstream new_file; new_file.open("new_file_write.txt",ios::out); if(!new_file) { cout<<"File creation failed"; } else { cout<<"New file created"; new_file<<"Learning File handling"; //Writing to file new_file.close(); ...

C++: 8. Polymorphism

Polymorphism is an important concept of object-oriented programming. It simply means more than one form. That is, the same entity (function or operator) behaves differently in different scenarios. Function Overloading in C++ In C++, two or more functions can have the same name if the number and/or type of parameters are different, this is called function overloading. Example:-  #include <iostream> using namespace std; int add(int a, int b) {     return a+b; } int add(int a, int b, int c) {     return a+b+c; } double add(double a, double b) {     return a+b; } int main() {   int x = 3, y = 7, z = 12;   double n1 = 4.56, n2 = 13.479;   cout<<"x+y = "<<add(x,y)<<endl;   cout<<"x+y+z = "<<add(x,y,z)<<endl;   cout<<"n1+n2 = "<<add(n1,n2);   return 0; } Output:-  x+y = 10 x+y+z = 22 n1+n2 = 18.039 Function Overriding in C++ When a member function of a base class is redef...