#

Hard Work Beats Talent – ANYONE Can Win!

Once we\'ve specified our city and state, we need to check if the state already exists in WordPress. The termexists() function checks if a term already exists and returns the data if it does. By setting the last argument to \"0\" we\'re only checking for terms without a parent, which would make sure it is a state. If the state doesn\'t exist, we\'re using wpinsert_term() to add it to the WordPress database.rnrnNow that we have the state figured out, we repeat the process for the city with one small change. Instead of using \"0\" as the parent ID in termexists(), we\'re going to use the state\'s ID to make sure we\'re getting the correct city. If the city hasn\'t been created for that state, we\'ll also need to specify the state ID in wpinsert_term().rnrnNow that we know we have the correct city and state data stored as terms, we just need to use their IDs in our $custom_tax array. This method could be expanded to include countries, or applied to something entirely different like genres.
  • Thích
  • ·
  • Trả lời
  • ·
  • Trả lời
  • {{comment.comment_time}}
Edit

View more comment

  • ·
  • Trả lời
  • {{comment_children.comment_time}}