- This topic has 13 replies, 2 voices, and was last updated 6 years, 5 months ago by
David.
-
AuthorPosts
-
November 3, 2019 at 8:49 am #1052118
Peery
Hey,
Ok… Having trouble inserting PHP into elementor… Created an element with…
<?php echo date('F jS' , strtotime(' + 14 days')); ?>And want to insert in a specific spot on page… Any way to do this easy?
[premium-date]
should show the element… or a better way to do this would be better 😉
Please let me know.. Thanks!
November 3, 2019 at 9:40 am #1052149David
StaffCustomer SupportHi there,
simplest way is to create a shortcode then you can add that to your content eg. this PHP snippet:
function display_premium_date() { echo date('F jS' , strtotime(' + 14 days')); } add_shortcode('premium_date', 'display_premium_date');Will create the
[premium_date]shorcode.Adding PHP:
https://docs.generatepress.com/article/adding-php/November 3, 2019 at 9:47 am #1052162Peery
Hey,
I added the php snippet to my functions.php file… and added the shortcode into elementor.. Didn’t show up.. See page. And.. cant say it enough David.. u da man!
November 3, 2019 at 9:48 am #1052165Peery
wait..
November 3, 2019 at 9:49 am #1052167Peery
nevermind… it works 😉 I used
[premium-date]instead of[premium_date]November 3, 2019 at 9:50 am #1052169Peery
Now I just have to figure out how to place within a sentence 😉
November 3, 2019 at 9:57 am #1052178David
StaffCustomer Supporthaha – yeah sorry i used an underscore 🙂
Inside a sentence your would need to use a HTML Widget then you can include the shortcode – should work in elementor eg.<p>Some text [premium_date] around the premium date</p>November 3, 2019 at 10:01 am #1052187Peery
Hey,
Ok.. peep the page for me please…
The 1st section is a heading widget… used same code
<p>Some text [premium_date] around the premium date</p>The 2nd section is a text editor widget.. using the same code
<p>Some text [premium_date] around the premium date</p>1st section is showing the date at the top left page after the header…
2nd section showing it above the paragraph..lol…. oh man..
November 3, 2019 at 10:02 am #1052188Peery
3rd section…. is an HTML widget… added the date at the top with the 1st section…
November 3, 2019 at 10:04 am #1052192November 3, 2019 at 10:08 am #1052197Peery
Thinking….
I could just add the code within the php snippet… I will try that.
November 3, 2019 at 10:09 am #1052199David
StaffCustomer SupportTry this for your shortcode:
function display_premium_date() { ob_start(); echo date('F jS' , strtotime(' + 14 days')); return ob_get_clean(); } add_shortcode('premium_date', 'display_premium_date');November 3, 2019 at 10:14 am #1052205Peery
Ok.. was in the process of changing… but tried ur updated code… and wallaahhh 😉 Thanks David!
November 3, 2019 at 10:15 am #1052206David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.