Skip to content

Jass Web

  • Home
  • Solved
    • javascript
    • c++
    • java
    • git
    • php
    • arrays
    • html
    • python
    • jquery
    • mysql
    • .net
    • json
    • ajax

post-meta

[Solved] Create custom field on post draft or publish?

October 6, 2022 by Kirat

Add an array and choose one for the value. add_action(‘draft_post’, ‘add_custom_field’); function add_custom_field($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { $colors = array(‘white’, ‘green’, ‘blue’); add_post_meta($post_ID, ‘random_color’, $colors[array_rand($colors, 1)], true); } } 2 solved Create custom field on post draft or publish?

Categories WordPress Tags custom-field, post-meta

Recent Posts

  • [Solved] Better way of replacing subtring from a string [duplicate]
  • [Solved] C++ generate random numbers for a given seed [closed]
  • [Solved] Single result from database using mysqli
  • [Solved] what does this code do? and how it will look on dart? [duplicate]
  • [Solved] How to rotate xticklabels in a seaborn catplot

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • November 2021
  • August 2020
  • March 2020
  • June 2019
  • February 2019
  • September 2018
  • August 2018
  • July 2018
  • March 2018
  • February 2018
  • December 2017
  • October 2017
  • August 2017
  • January 2017
  • September 2016
  • May 2016
  • January 2016
  • October 2015
  • July 2015
  • February 2015
  • December 2014
  • November 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • March 2014
  • January 2014
  • January 2013
  • October 2012
  • March 2012
  • October 2011
  • March 2011
  • January 2010
  • September 2009
  • May 2009
  • February 2009
  • January 2009
  • October 2007
  • January 2007
  • November 2004
  • May 2002
  • September 2001
  • May 2001

Categories

  • Solved
  • WordPress
© 2023 Jass Web • Built with GeneratePress