Title: PHP in Patterns?
Last modified: April 4, 2024

---

# PHP in Patterns?

 *  [oguruma](https://wordpress.org/support/users/oguruma/)
 * (@oguruma)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/php-in-patterns/)
 * I’d like to allow users to add custom galleries in their theme’s single templates.
   The actual images would be pulled from the backend based on some post meta that
   represents the gallery images.
 * Can I create the pattern as a php file in the theme’s patterns directory?

Viewing 1 replies (of 1 total)

 *  [ramonopoly](https://wordpress.org/support/users/ramonopoly/)
 * (@ramonopoly)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/php-in-patterns/#post-17553248)
 * > Can I create the pattern as a php file in the theme’s patterns directory?
 * Do you mean a theme that you’re creating (and therefore have full control over)?
 * If so, then yes, you can create patterns in PHP and place them in the `/patterns`
   directory.
 * See: [https://developer.wordpress.org/themes/features/block-patterns/#registering-block-patterns](https://developer.wordpress.org/themes/features/block-patterns/#registering-block-patterns)

Viewing 1 replies (of 1 total)

The topic ‘PHP in Patterns?’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [ramonopoly](https://wordpress.org/support/users/ramonopoly/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/php-in-patterns/#post-17553248)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
