Quick tip: set post connector using PHP code

I actually wrote about this back in April, but it’s such a nice feature that it’s worth mentioning again (also: I had forgot about this myself!):

You can use PHP to set the Post Connector for a post. This has some nice benefits:

  • Post Connectors can be set automatically (no user has to select something is a dropdown)
  • Post Connectors can be set based on Post ID, Tags, Categories, what ever you want or need
  • If you set the Post Connector using code you can then hide the post connector dropdown completely from the edit post screen = much cleaner and more easy to use interface

Some code examples to get you started:

Get maximum number of attached fields to any post

In a recent project I needed to get the maximum number of attached files to any post. The files were of course added to my posts by using Simple Fields and a repeatable field group.

Since this was the first time I’ve ever needed to do this, there was no built in functions for this.

Anyway, turned out to be pretty straightforward. The solution for me was this: Continue reading