WordPress.org

Support

Support » Plugins and Hacks » Hacks » Create custom field from Post date

Create custom field from Post date

  • Hi,

    Is it possible to automatically create a custom field to contain the ‘Month‘ from the post date?

    The field can either be numeric or text.. eg. 04 or April

    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • It’s possible… but there’s really not much need for this. Anywhere that you need the month from it you can use the post date and format it using some simple PHP functions to show only the month.

    What exactly do you want to do with this custom field anyway?

    Hi Michael

    Thanks for such a quick reply.

    I’m working on website that needs to display a list of posts in a specific category for each month of the year. My client wants these posts set out in a grid/calendar like format. (Unfortunately all the event type plugins didn’t quite meet the requirements). So to achieve this, I’ve created a table and I’m using the ‘Special Recent Posts PRO’ plugin and placing shortcodes from the plugin in the appropriate place in the table.

    The plugin allows me to filter by category no problem, but I need filter by month also and so I thought of using a custom field for this.

    If there is a better way then I am open to suggestions. My PHP knowledge is limited but if I’m pointed in the right direction I should be ok.

    Many thanks again.

    Brad

    Hi Michael

    Actually, I’ve realised that my original query is not correct. The posts act like ‘events’ and even though I am publishing the posts they actually have a date (some time in the future) in another custom field that I need extract the month from.

    Is this possible?

    Hope this is clear.

    Thanks

    Brad

    Yes, it’s definately possible. But… I don’t know that extension, so I can’t do to much with that. My main suggestion is to look in the code for that plugin and see what the query is in the function that’s called from that shortcode. There should be a call to add_shortcode(‘shortcode’, ‘function_name’) so find that for the shortcode that you’re looking for and that will tell you the function that it’s calling. Then find that function and see where it’s doing it’s search and you should b able to modify the query there.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Create custom field from Post date’ is closed to new replies.
Skip to toolbar