Monday, December 25, 2023

Code to Load more isotope Divis Using Jquery Ajax

 <script>

$(document).ready(function() {


$('.team-filters ul li a').click(function() {

$('.team-filters ul li a').removeClass('active');

$(this).addClass('active');


});


// var selector = $(this).attr('data-filter');

var $container = $('.isotope').isotope({

filter: $container,

itemSelector: '.element-item',

});


$('#filters').on('click', 'a', function() {

var filterValue = $(this).attr('data-filter');

// use filterFn if matches value

// filterValue = filterFns[filterValue] || filterValue;

$container.isotope({

filter: filterValue

});

});


$container.imagesLoaded(function() {

$container.isotope('layout');

});


// return false;



var initShow = 6;

var counter = initShow; 

var iso = $container.data('isotope'); 


loadMore(initShow); //execute function onload


function loadMore(toShow) {

$container.find(".hidden").removeClass("hidden");


var hiddenElems = iso.filteredItems.slice(toShow, iso.filteredItems.length).map(function(item) {

return item.element;

});

$(hiddenElems).addClass('hidden');

$container.isotope('layout');


//when no more to load, hide show more button

if (hiddenElems.length == 0) {

jQuery("#load-more").hide();

} else {

jQuery("#load-more").show();

};

}


//append load more button

// $container.after('<button id="load-more"> Load More</button>');


//when load more button clicked

$("#load-more").click(function(event) {

event.preventDefault();

if ($('#filters').data('clicked')) {

//when filter button clicked, set initial value for counter

counter = initShow;

$('#filters').data('clicked', false);

} else {

counter = counter;

};

counter = counter + initShow;

loadMore(counter);

});


//when filter button clicked

$("#filters").click(function() {

            // alert("sd;lk");

$(this).data('clicked', true);

loadMore(initShow);

});



});

</script>

Thursday, November 2, 2023

Woocommerce custom user redirect

 function wc_custom_user_redirect( $redirect, $user ) {
    // Get the first of all the roles assigned to the user
    $role = $user->roles[0];
    $dashboard = admin_url();
    $myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
    if( $role == 'administrator' ) {
        //Redirect administrators to the dashboard
        $redirect = $dashboard;
    } elseif ( $role == 'seller' ) {
        $redirect = site_url()."/dashboard";
    }elseif ( $role == 'sales' ) {
        //Redirect Sales team to the dashboard
        $redirect = $dashboard;
    }elseif ( $role == 'editor' ) {
        $redirect = home_url();
    } elseif ( $role == 'author' ) {
        $redirect = home_url();
    } elseif ( $role == 'customer' || $role == 'subscriber' ) {
        //Redirect customers and subscribers to the "My Account" page
        $redirect = $myaccount;
    } else {
        //Redirect any other role to the previous visited page or, if not available, to the home
        $redirect = wp_get_referer() ? wp_get_referer() : home_url();
    }
    return $redirect;
}
add_filter( 'woocommerce_login_redirect', 'wc_custom_user_redirect', 10, 2 );

Friday, October 13, 2023

Pause Iframe video on Pop up close button With jQuery

 Remove Iframe SRC attribute

jQuery('#cls-<?=get_the_ID(); ?>').click(function(){
jQuery("#popModal<?=get_the_ID(); ?>").hide();
jQuery("#popModal<?=get_the_ID(); ?> iframe").attr("data-src",jQuery("#popModal<?=get_the_ID(); ?> iframe").attr("src"));
                           jQuery("#popModal<?=get_the_ID(); ?> iframe").removeAttr("src");
                             jQuery("body").removeClass('popupOn');
                         });


Add Iframe SRC attribute                        

jQuery('#popBtn<?=get_the_ID(); ?>').click(function(e){
                             //jQuery("#popModal<?=get_the_ID(); ?> iframe").attr("src",jQuery("#popModal<?=get_the_ID(); ?> iframe").attr("data-src"));
                             //jQuery("#popModal<?=get_the_ID(); ?> iframe").removeAttr("data-src");
jQuery("#popModal<?=get_the_ID(); ?>").show();
                             jQuery("body").addClass('popupOn');
                         });

Thursday, September 14, 2023

How to add additional class to WordPress navbar anchors

 

//Function In function .php

function add_additional_class_on_a($classes, $item, $args)
{
    if (isset($args->add_a_class)) {
        $classes['class'] = $args->add_a_class;
    }
    return $classes;
}
add_filter('nav_menu_link_attributes', 'add_additional_class_on_a', 1, 3);

//Code for Header.php

 <?php

                $web_menu = wp_nav_menu(array(

                'theme_location' => 'menu-1',

                'menu_id' => 'primary-menu',

                'menu_class' => 'navbar-nav',

                'add_a_class' => 'nav-link', //Here is the class

                 'container' => 'ul',

                'echo' => false

            )

            );

            $web_menu = str_replace('menu-item', 'nav-item', $consult_menu);

                echo $web_menu ;

            ?>

Friday, September 1, 2023

What is WordPress Uses?

 In WordPress, "Users" refer to individuals who have access to your WordPress website's admin area. Each user account can have different roles and permissions, which determine their level of access and what they can do on the website. Managing user accounts is essential for controlling who can make changes to your site's content and settings. Here's an overview of WordPress users and user roles:

  1. User Roles:

    • Administrator: Administrators have full control over the WordPress site. They can add, edit, or delete content, install plugins and themes, manage other users, and change site settings. There can be multiple administrators.
    • Editor: Editors can create, edit, publish, and delete all types of content on the website, including posts, pages, and media. They cannot modify website settings or install plugins or themes.
    • Author: Authors can create, edit, publish, and delete their own posts. They do not have access to other users' content or settings.
    • Contributor: Contributors can write and edit their own posts, but they cannot publish them. They need an editor or administrator to review and publish their content.
    • Subscriber: Subscribers have the least access. They can only manage their user profile and receive email notifications about new content.
  2. Managing Users:

    • To manage users, log in to your WordPress Dashboard and go to "Users."
    • You can add new users, edit existing user profiles, change their roles, and reset passwords if necessary.
    • Be cautious when assigning roles. Only grant the level of access required for each user's responsibilities to maintain security.
  3. User Registration:

    • By default, WordPress allows users to register on your site. You can enable or disable user registration in the "General Settings."
    • Registered users can comment on posts, and you can also assign roles to new users upon registration.
  4. Multisite:

    • In WordPress Multisite, there are Super Admins who have control over the entire network, and there are site-specific admins for each sub-site within the network.
  5. User Profile:

    • Each user has a profile where they can edit their personal information, set their profile picture (avatar), and change their password.
  6. User Plugins:

    • WordPress allows you to extend user management through various plugins. For example, membership plugins can help restrict content to specific user groups, and social login plugins allow users to log in with their social media accounts.

User management is crucial for ensuring the security and integrity of your WordPress website. By assigning appropriate roles and permissions to users, you can maintain control over who can create, edit, and manage content while keeping your site protected from unauthorized changes.

Tuesday, August 29, 2023

Wordpress Tools

 In WordPress, the "Tools" section encompasses various tools and features that aid in managing and maintaining your website's content, data, and overall performance. These tools are designed to make your experience as a website owner or administrator more efficient and streamlined. Here's an overview of some of the key tools available in WordPress:

To access the Tools section, log in to your WordPress Dashboard and navigate to "Tools" on the left-hand menu.

  1. Available Tools:

    • Import: Allows you to import content from other platforms or systems. For example, you can import content from another WordPress site, Blogger, Tumblr, or an RSS feed.
    • Export: Lets you create a backup of your site's content, including posts, pages, comments, categories, and tags. You can then import this backup into another WordPress site.
  2. Press This (Deprecated):

    • Press This was a tool that allowed you to quickly share content from the web to your WordPress site. It's no longer actively maintained and has been removed in recent versions of WordPress.
  3. Categories and Tags Converter:

    • This tool helps you convert categories to tags or tags to categories. It can be useful if you're restructuring your content organization.
  4. Import and Export:

    • Import and Export are tools that assist in moving content between different WordPress websites or other content management systems.
  5. Site Health:

    • This feature provides information about the health of your website, including performance and security. It offers recommendations for improvements and ensures your site is up to date and running smoothly.
  6. Export Personal Data and Erase Personal Data:

    • These tools help you comply with data protection regulations like GDPR. You can provide users with their personal data and even erase it if necessary.
  7. Block Editor:

    • While not traditionally part of the "Tools" section, the Block Editor (Gutenberg) is a powerful tool in WordPress for creating and managing content using blocks. It provides a visual and modular approach to content creation.
  8. Database Optimization and Cleanup (via Plugins):

    • There are third-party plugins available that help optimize and clean up your WordPress database, which can improve performance and reduce clutter.

Remember that the availability and functionality of these tools might vary based on your WordPress version, theme, and installed plugins. The "Tools" section is designed to make various administrative tasks more accessible, whether you're migrating content, maintaining data privacy, or optimizing your website's performance.

Wednesday, August 23, 2023

WordPress Settings

 In WordPress, the "Settings" section refers to the part of the WordPress Dashboard where you can configure various global settings that affect the overall behavior, appearance, and functionality of your website. These settings control how your site operates, displays content, interacts with users, and more. Here's an overview of the different settings you can adjust in WordPress:

To access the Settings section, log in to your WordPress Dashboard and navigate to "Settings" on the left-hand menu.

  1. General Settings:

    • Site Title: The name of your website.
    • Tagline: A brief description or slogan for your site.
    • WordPress Address (URL): The URL where your WordPress core files are located.
    • Site Address (URL): The URL where your website is accessible to visitors.
    • Timezone: Set the timezone for your site's publishing schedule.
    • Date Format: Choose how dates are displayed on your site.
  2. Writing Settings:

    • Default Post Category: Choose a default category for new posts.
    • Default Post Format: Choose a default format for new posts.
    • Post via email: Allow posts to be created via email.
    • Update Services: Notify update services when you publish new content.
  3. Reading Settings:

    • Front page displays: Choose between displaying your latest posts or a static page on the front page.
    • Blog pages show at most: Set the number of posts displayed per page.
    • Search Engine Visibility: Discourage search engines from indexing your site (useful during development).
  4. Discussion Settings:

    • Default article settings: Set defaults for comments and pingbacks.
    • Other comment settings: Configure settings related to comments and notifications.
    • Avatars: Choose how avatars are displayed in comments.
  5. Media Settings:

    • Image sizes: Configure default sizes for thumbnails, medium, and large images.
    • Uploading files: Choose the folder and structure for organizing uploaded media.
  6. Permalinks Settings:

    • Common settings for URLs: Choose the structure of your website's permalinks (URLs).
  7. Privacy Settings:

    • Privacy Policy Page: Select a page to display your privacy policy.

These settings provide control over essential aspects of your WordPress website. It's important to review and configure these settings according to your website's goals and requirements. However, be cautious when making changes to settings that you're not familiar with, as they can impact how your website operates.

Keep in mind that the exact settings available to you might vary depending on your WordPress version, theme, and any plugins you have installed. Always remember to save your changes after making adjustments to settings.

1 hour Free Service for WordPress website :)

      1 hour Free Service for WordPress website :)