• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

BUG Available Attributes

Messages
1
Likes
0
Points
1
#1
Hi Guys

The blog posts on my site are player profile pages where I use your plugin to display their current ages, using snippets like this:

Code:
  $dateOfBirth = "01-08-1988";
  $today = date("Y-m-d");
  $diff = date_diff(date_create($dateOfBirth), date_create($today));
  echo $diff->format('%y').' years';
I am currently doing a new snippet for each player, changing their dates of birth as appropriate. This means I have hundreds of snippets now created, with many more to go.

I have looked at the "Available Attributes" section of the Edit php snippet screen and was wondering if this could be used to create one single snippet where I add the date on the blog page with the snippet shortcode, rather than create separate snippets. I have tried but can't make it work - I am not a coder, so I don't know if it's me doing something wrong, or if I have just totally misunderstood what the Available Attributes section actually does.

Thanks!
 

Temyk

Developer & Support
Staff member
Messages
1,068
Likes
39
Points
48
#2
Hello.

You can add attributes to the shortcode. In your case, you can pass the date of birth through the attribute. The description of this option describes how it works.

But in your case, it is better to write a code that will automatically receive the date of birth from the post and output it in the desired form. But for this you need to be able to program in PHP and Wordpress