Support

Account

Home Forums Backend Issues (wp-admin) Restrict meta value to only be assigned once Reply To: Restrict meta value to only be assigned once

  • Great John thanks for the link!

    Looks like this could point me in the right direction..

    My situation is slightly more complex as I need prevent duplicate values only in posts that share a taxonomy.

    For example, let’s say my CPT is called ‘knowledge base’ and I have a custom taxonomy called ‘topics’ with 5 terms ‘topic A, topic B, topic C, topic D, topic E,’.

    I also have a numeric meta key called ‘top_four’, this determines the order of the top four post links displayed under the term name (the remaining posts are hidden via a read more button). So, with 5 terms I would need to apply the meta value of ‘1’ five times (each per taxonomy term), along with values 2,3 and 4.

    You can see where my challenge starts to occur as the meta value needs to be duplicated 5 times in CPT, but only should be allowed to be used once within its term.

    I am wondering if I can use a loop to apply the rule you outlined in your other post on a per term basis, maybe a foreach loop that applies the rule.

    Thanks once again John