Limited availability during the holidays

Another busy year is coming to its end, and an exciting year lies ahead. In order to get ready for a fresh new start, our team will spend a few days' rest during the winter holidays. Over the holiday break, we will have reduced staffing from December 20th, 2024, to January 5th, 2025, so please be patient if you do not receive a response as quickly as you normally would.

We send our warmest wishes for happiness, health, and success throughout the coming year. Thank you for your continued support, and may you have a peaceful and blessed Happy Holidays!

Okay
  Public Ticket #3484421
using php in elementor
Closed

Comments

  • Ed Rosenthal started the conversation

    putting in place the php code <?php layerslider(6, '1287'); ?> in an elementor side ( not sure that matters). 

    1287 is the template code, but i have also tried Home, homepage, and 140 ( the page id ) and none of these seem to work. I only want the slide to show on the home page, but the template in which it lives is for all pages, but the issue first is the php doesn't show the slide ( id 6 ). any suggestions?

  •  73
    John replied

    Hi Ed,

    Thank you for getting in touch with us. My name is John, and I'm happy to assist you today. I appreciate your patience while we've been working toward your ticket.

    Please note that you can't use PHP code in Elementor. However, you can add a Shortcode widget to your template and use the respective LayerSlider shortcode to embed your projects. In your case, it would be: 

    [layerslider id="6" filters="homepage"]

    The slider might not appear in Elementor's preview since it uses the "homepage" filter. 

    Best Regards,
    John | Kreatura Dev Team

  • Ed Rosenthal replied

    John, thanks for the reply.

    however i want to affirm yes you can use Php ( using the code widget, with the setting on php).

    Also i did try using short code, and am using it currently again. Also see attached should show the shortcode being used.

    Attached files:  LS Shortcode.jpg

  •  73
    John replied

    The shortcode on the attached screenshot doesn't include the filters="homepage" part, which should ensure that the slider is only visible on the home page. Based on your initial message, it seemed that was the problem you experienced.

    After revisiting your site, I've noticed an "Uncaught ReferenceError: jQuery is not defined" JavaScript error that prevents LayerSlider from displaying your slider. It's likely due to caching/site optimization plugins and services, which force loading the jQuery library at the footer.

    Please navigate to Plugin Settings → Performance, and enable the "Include scripts in the footer" option. That should fix this issue, but please be aware that your site uses caching and potentially a CDN service, so you might need to manually purge the cached contents to see the changes you made.

    Best Regards,
    John | Kreatura Dev Team

  • Ed Rosenthal replied

    Thanks, 

    well i am trying out the suggestion of the filter="homepage", but it gets an error on the frontend. see attached.(it also when i added the shortcode removed the slider from the editor).

    using the siteground optimizer in this, the development site, i turned off defering rendering see attached.

    also the snapshot of the shortcode modified with the filter.

    suggestions welcome!

    Attached files:  error-using-filter.jpg
      sg-optimizer-js-settings.jpg
      filter-with-homepage.jpg

  •  73
    John replied

    It's normal that Elementor's editor doesn't show the slider when embedded with the "homepage" filter since the preview is not actually your home/front page. The filter is needed if you insert the shortcode into a site part that gets loaded on every page (e.g., header area), but you want the slider to be displayed only on the home page. 

    Is there a reason why you try to embed the slider into the header area instead of editing your home page? LayerSlider has its own dedicated Elementor widget with lots of customization options and integration features that you could use if you edit a page instead of a site part.

    I've rechecked your site, but the slider doesn't seem embedded, so I couldn't investigate what caused the error.

    Best Regards,
    John | Kreatura Dev Team

  • Ed Rosenthal replied

    Thanks John, 

    I think this latest round of changes has solved the issue. It is showing up ( the metered with numbers layerslider) on mobile now ( at least on my iphone). I removed the sg optimizer ( nothing with it seemed to work) and put back wp rocket. I removed the shortcode from the template and just used the home page, as you wisely suggested. and got an A from gtmetrix for performance. the layerslider now shows up after everything else though, so it is counter intuitive to see the A in the report. the wp rocket settings are ( in file optimization) minify css files, optimize css delivery, remove unused css, minify javascript files, load javascript deferred, delay javascript execution. if i wanted to exclude javascript files in the delay portion, what would i put in the excluded javascript files box? Thanks so much for your support!

    Attached files:  exclusions.jpg

  •  73
    John replied

    I'm glad to hear that everything is on the right track now!smile.png The slowness is definitely due to WP Rocket's Delay JavaScript Execution feature. WP Rocket has a built-in exclusion list dedicated to LayerSlider, but you can just open the Plugins dropdown menu visible on your screenshot and check the LayerSlider entry for an even more convenient solution.

    Best Regards,
    John | Kreatura Dev Team

  • Ed Rosenthal replied

    thanks again! 

  • Ed Rosenthal replied

    oddly, the slider stopped again showing up on my iphone. this is becoming a dilemma inside a riddle inside a conundrum.

    i am sending a pic of the rocket settings. any suggestions welcome.

    but as it turns out, it shows up ok on my wife's iphone just fine.

    it has to be the phone i am using. 

    ok final update - after clearing both browsers on my iphone it shows up in either one. i think i can safely say this was a tortured learning experience. thanks again!

    Attached files:  rocket-settings.jpg

  •  73
    John replied

    I'm glad that everything is working out okay! It also works okay on my end, tested on various devices. Caching can be tricky, and unfortunately, we can't do much on our side to control these things.

    Best Regards,
    John | Kreatura Dev Team