Movable Type: Specify only one keyword from MTEntryKeywords
I have several keywords (1~3 words) stored in <MTEntryKeywords>
field separated by commas.
I want to take out the first keyword from MTEntryKeywords.
Example 1:
In the Keywords field I have entere开发者_如何学编程d: gadgets,phone,apple,
Want to display: gadgets
Example 2:
In the Keywords field I have entered: food,coffee,apple,
Want to display: food
Any ideas?
This is untested, but something like this should do the trick (assuming you're using a recent enough version of MT)
<mt:entrykeywords regex_replace="/^([^,]+)(,.*)?$/","$1">
Basically, the regular expression there is saying "keep only everything up to, but not including, the first comma".
精彩评论