Hi @singinggardener,
Can you provide a bit more information on your data organization and frontend output?
For example, as all post types already have two dates associated with them, it’s often not necessary to associate a new field for derive a month.
All the same, if you have created an additional field associating a month with some content:
- What type of content are you displaying? A post type named X? Plant?
- What data type are your months? A date field? A relationship to a post type named “month”? A relationship or connection to a taxonomy named “month? A simple relationship list of month names?
- What language are your months displayed in?
- You mentioned it’s a “table setting”. Are you displaying a calendar of the month? How are you displaying your calendar?
- Where would you like to store your images? An image field associated with a relationship to a month post type or taxonomy term? Or would just some one-off URLs to images in the media library be sufficient?
Generally speaking, in a Pods context, if you have a post type or taxonomy named “month” related to another post type named “plant” via a field named “rel_month”, and “month” has an image field named “icon”, the URL of the medium image size stored in “icon” can be output in a Pods template from a context of querying the plant with magic tag {@rel_month.icon._src.medium}
.
If “month” is a taxonomy associated with “plant” via the connections tab, and “icon” is still on “month”, the medium image URL can be output with {@month.icon._src.medium}
.
Once you have the URL, one can either put it in the src
attribute of an <img>
tag, or background-image: url( ... );
in CSS. If ._src.medium
is removed from the magic tags, a full <img>
tag with src
and CSS classes already filled in will be output.
If more complex functionality is desired, some PHP functions to consider include strtotime(), which can derive a timestamp from an already-existing date/time field, date(), which can output a month name from a timestamp using date( ‘F’, strtotime( $date_string ) ); or strftime(), which works the same as date()
but will output in the language set by setlocale(). There is also WordPress-specific date_i18n(), which is like strftime()
, but automatically uses the current language of the site.