Search
Close this search box.
Search
Close this search box.

Elementor

How to change the background color on a fixed header?

  1. Open your Elementor header.
  2. Set it to sticky.
  3. In Effects offset enter a value, eg. 100.
  4. Click Advanced > Custom CSS and add this code.
selector.elementor-sticky--effects {
    background-color: red;
}

How to make a marquee with elementor carousel

  1. Add the elementor Carousel widget.
  2. Remove navigation and pagination.
  3. Set the transition duration.
  4. Make the slide full width.
  5. Insert into the slide whatever you want to be repeated (eg. a heading).
  6. Duplicate the slide 3-4 times.

Apply this CSS to it:

selector .swiper-wrapper {
-webkit-transition-timing-function: linear !important;
transition-timing-function: linear !important;
}

selector .swiper-slide {
width: max-content !important;
}

Boxed padding

/*boxed-padding*/
.e-con,
.e-con-inner{
--content-width-full: min(100vw, var(--container-max-width, 1140px));
--boxed-padding:calc((100vw - var(--content-width-full))/2);
}

Close popup on clicking a btn with a class on it

<script>
jQuery( document ).ready( function( $ ) {
$( document ).on( 'click', '.close-popup', function( event ) {
elementorProFrontend.modules.popup.closePopup( {}, event );
} );
} );
</script>

How to remove image captions from lightbox

.elementor-slideshow__footer {
    display: none !important;
}

How to add infinite loop in motion effects

Create the animation using Motion Effects section.
Go to Custom CSS section and add the following code:

selector { animation-iteration-count: infinite; animation-direction: alternate-reverse; /*optional*/ }

How to add counter in swiper

<script>
jQuery( document ).ready(function(){

var swiper_container = document.querySelector('.swiper-container');
if(swiper_container){
 
var swiper = swiper_container.swiper;
swiper.on('transitionEnd', function() {
change_counter()
});
swiper.on('slideChange', function() {
change_counter()
});

function change_counter(){
var index =  swiper.realIndex + 1;
var slides_length =  swiper.slides.length
jQuery(".swiper-mobile-counter .elementor-widget-container").html(index + " / " + slides_length);
}
}
 
});
</script>

How to span 2 columns on a flex grid

Click the element in the grid you want to span and add this is Custom CSS:

selector {
grid-column: auto / span 2;
}

How to offset on item on a flex grid by one column

Click the element in the grid you want to span and add this is Custom CSS:

selector {
grid-column: 2/3;
}

How to colorize form input placeholder

input::placeholder, textarea::placeholder {
color: #F5EDE3 !important;
opacity: 1 !important;
}

How to move a carousel by using custom buttons

<script>
jQuery(document).ready(function($) {
function getSwiperInstance2() {
var swiperTarget2 = $('#process-carousel .swiper');
return swiperTarget2.data('swiper');
}
$('#prev-process').on('click', function() {
getSwiperInstance2().slidePrev(500, true);
});
$('#next-process').on('click', function() {
getSwiperInstance2().slideNext(500, true);
});
});
</script>

How to make an image carousel scroll continuously

  1. In additional options set autoplay speed 0.
  2. Set also animation speed 5000.
  3. In advanced CSS add this code:
selector .swiper-wrapper {
-webkit-transition-timing-function: linear !important;
transition-timing-function: linear !important;
}

How to make a grid with and accordion on the left and an image that changes on the right

Make a grid and use a slider on the right column.

The classes you need to add are:

toggle-txt-imgs
toggle-txt
toggle-imgs

And here is the script:

<script>
jQuery(document).ready(function(){

  var toggle_tab = '.toggle-txt .elementor-tab-title';

jQuery(document).on('click', toggle_tab, function(){ 
//debugger;
var container = jQuery(this).closest(".toggle-txt-imgs");
var accordion_item = jQuery(this).closest(".elementor-accordion-item"); 
var accordion_items = container.find(".elementor-accordion-item"); 
var tab_num = accordion_items.index(accordion_item);
var toggle_imgs = container.find(".toggle-imgs .swiper");
var toggle_imgs_swiperInstance = toggle_imgs.data( 'swiper' );
toggle_imgs_swiperInstance.slideTo( tab_num );
})
    
});


</script>

How to change a swiper for mobile only on load

<script>
jQuery( document ).ready(function(){


//Function to check if browser is mobile
window.mobileCheck = function() {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
return check;
};


if(window.mobileCheck()){
function getSwiperInstance2() {
var swiperTarget2 = jQuery('.team-members-carousel .swiper');
return swiperTarget2.data('swiper');
}


function checkFlag() {
if(typeof(getSwiperInstance2()) === 'undefined') {
window.setTimeout(checkFlag, 100); /* this checks the flag every 100 milliseconds*/
} else {


getSwiperInstance2().slideNext(0, true);
}
}
checkFlag();


}
});
</script>

Fix: Sticky Header Overlaps Anchor in Elementor

  1. Use only Elementor anchor widgets (and not IDs on elements)
  2. Add the CSS code below.
body:not(.elementor-editor-active) .elementor-widget-menu-anchor {
position: relative;
z-index: -1;
}
body:not(.elementor-editor-active) .elementor-widget-menu-anchor .elementor-menu-anchor:before {
content: "";
display: block;
height: 100px; 
margin: -100px 0 0; 
visibility: hidden;
pointer-events: none;
}

How to do any query inside loop grid-carousel 

function loop_carousel_codemine_events( $element ) {
$widget_name = $element->get_name();
if($widget_name == "loop-carousel"){
$settings = $element->get_settings();
if($settings["post_query_query_id"] == 'codemine_events'){
$today = new DateTime(date('Y-m-d'));
$events = CMCAL()->dal->get_events($today, $today, null, null , false);
$events_ids = array_column($events, 'id');
add_action('elementor/query/codemine_events', 
function($query) use ($events_ids) { 
$query->set( 'post__in', $events_ids );
});
}
}
}

How to use ACF gallery in loop carousel

add_action( 'elementor/frontend/widget/before_render', 'loop_carousel_venue_images' );

function loop_carousel_venue_images( $element ) {
// venue_images is the Query ID
$widget_name = $element->get_name();
if($widget_name == "loop-carousel"){
$settings = $element->get_settings();
if($settings["post_query_query_id"] == 'venue_images'){
$images = get_field('venue_gallery');
add_action('elementor/query/venue_images', 
function($query) use ($images) { 
$query->set( 'post_type', [ 'attachment' ] );
$query->set( 'post_status', [ 'inherit' ] );
$query->set( 'post__in', $images );
});
}
}
}

//Shortcode for the image
//Use this to display the image inside loop item
add_shortcode ("venue_gallery_image", "venue_gallery_image_func");

function venue_gallery_image_func($atts){
return '<img src="' . wp_get_attachment_url(get_the_ID()) . '">';
}

How to remove focus from buttons in elementor

selector a.elementor-item:focus {
outline: none;
}

And for images (eg. logo):

selector a:focus { 
outline: none;
}

Elementor loop grid’s post taxonomy custom query not working

add_filter( 'elementor/loop_taxonomy/args', 'elementor_loop_taxonomy_args', 20, 3 );


function elementor_loop_taxonomy_args( $args, $settings, $display_settings ) {
//print_r($settings['term_taxonomy_id']);
if( isset( $settings['term_taxonomy_id'] ) && $settings['term_taxonomy_id'] === 'product_cats_query' ) {
$args['term_taxonomy_id'] = '';
$args["orderby"] = "menu_order";
}
return $args;
}

Hot to hide empty accordion items

<script>
jQuery(document).ready(function(){
var emptyDivs = jQuery(".e-n-accordion-item > div");
emptyDivs.each(function(){
if(jQuery.trim(jQuery(this).text()) == ''){
if(jQuery(this).find("iframe").length == 0){ 
jQuery(this).parent('.e-n-accordion-item').hide();
}
}
});
});
</script>

How to fix horizontal scrollbar appearing

Add this in the page:

selector {
overflow-x: hidden
}
html { 
overflow:auto; 
}

How to change the styling and add an icon to elementor upload form button

Css:

selector .elementor-field-type-upload label{
background: url(/wp-content/uploads/2024/04/PlusCircle.svg);
background-repeat: no-repeat;
background-size: 32px;
background-position:left center;
content:'';
width: 32px;
height: 32px;
padding-left: 44px;
display: flex;
width: 100%;
padding-top: 2px;
}

selector input[type=file]{
display: none;
}

selector .uploaded-filename {
padding-left: 44px;
}

Javascript:

<script>
jQuery(document).ready(function(){
jQuery(document).on("change", "input[type=file]", function(){

jQuery(this).val();

var filename = jQuery(this).val().replace(/C:\\fakepath\\/i, '');
var container = jQuery(this).parent(".elementor-field-type-upload");

if(container.find(".uploaded-filename").length == 0){
container.append("<div class='uploaded-filename'></div>");
}

container.find(".uploaded-filename").html(filename);

});
});
</script>

How to add counter in swiper

<script>


window.addEventListener( 'elementor/frontend/init', () => {
jQuery(document).ready(function( $ ) {
(async() => {
//console.log("waiting for swiper");
while(typeof Swiper === "undefined") 
await new Promise(resolve => setTimeout(resolve, 100));
//console.log("swiper is now defined");


jQuery('.swiper-with-counter .swiper').each(function(){
//debugger;
var swiper_inst = jQuery(this)[0].swiper;
change_counter(swiper_inst);
swiper_inst.on('transitionEnd', function() {
change_counter(swiper_inst);
});
swiper_inst.on('slideChange', function() {
change_counter(swiper_inst);
});
})


})();
});
function change_counter(swiper_inst){
//debugger;
var index =  (swiper_inst.realIndex / swiper_inst.loopedSlides) + 1;
var slides_length = (swiper_inst.slides.length - swiper_inst.loopedSlides*2)  / swiper_inst.loopedSlides;
console.log(slides_length);
slides_length = Math.round(slides_length);
var counter = jQuery(swiper_inst.$el).closest(".swiper-with-counter").find(".swiper-counter .elementor-widget-container");
counter.html(index + "/" + slides_length);
}
} ); 
</script>