PHPackages                             carawebs/wp-metadata-accessor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. carawebs/wp-metadata-accessor

ActiveLibrary[Database &amp; ORM](/categories/database)

carawebs/wp-metadata-accessor
=============================

This package helps fetch data from the WordPress postmeta table.

1.0.4(9y ago)032GNUPHP

Since Mar 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Carawebs/wp-metadata-accessor)[ Packagist](https://packagist.org/packages/carawebs/wp-metadata-accessor)[ RSS](/packages/carawebs-wp-metadata-accessor/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (6)Used By (0)

WordPress Metadata Access
=========================

[](#wordpress-metadata-access)

Access WordPress data held in the postmeta table.

Usage
-----

[](#usage)

Run:

```
composer require carawebs/wp-metadata-accessor
```

Examples: Simple Postmeta Field Data
------------------------------------

[](#examples-simple-postmeta-field-data)

From within theme files, instantiate `Carawebs\DataAccessor\PostMetaData`.

You can then easily return field data by means of the `PostMetaData::getField()` method.

```
PostMetaData::getField( string $fieldName, string $filter)

```

Sample usage:

```
$postMeta = new Carawebs\DataAccessor\PostMetaData;

// returned content, unfiltered
$extra_content = $postMeta->getField('extra_content');

// returned content, filtered by `esc_html()`
$intro_text = $postMeta->getField('intro_text', 'text');

// returned content, filtered by `esc_html()`
$intro_text = $postMeta->getField('intro_text', 'esc_html');

// returned content filtered by WordPress 'the_content' filter
$extra_content = $postMeta->getContentField('extra_content');
```

Returned Data
-------------

[](#returned-data)

The `PostMetaData::getField()` method accepts an optional string denoting the field type as a second parameter. This is used to determine the filtering method that should be applied to the returned data.

If you're using ACF fields you don't specify a field type - this is determined automatically.

### Returned Data Processing

[](#returned-data-processing)

ParameterFilter or Method Used on `$content`"relationship"`Data::relationship(array $postIDs, $returnFormat = NULL)`: returns either an array of post IDs or customised post objects"image"`Data::image($id, $returnFormat = NULL)`: returns either an image data array, object, url or ID"esc\_html"`esc_html($content)`"text"`esc_html( $content )`"esc\_url"`esc_url( $content )`"the\_content"`apply_filters( 'the_content', $content )`"wysiwyg"`apply_filters( 'the_content', $content )`"date"`date( 'M j, Y', strtotime( esc_html( $content ) ) )`"float"`(float)$content`"int"`(int)$content`"OEmbed"None"object"NoneUnrecognized string`wp_kses_post($content)`ACF Repeater Field Data
-----------------------

[](#acf-repeater-field-data)

Fetch repeater field data from post\_meta table. Returns subfield data grouped by "row" into arrays.

ACF repeater field data is stored in the postmeta table as a collection of records. Repeater fields allow the editor to add as many groups of subfields as necessary.

The repeater field key returns an integer value that represents the number of repeater field records - this allows each record to have a unique index. The subfields are created by concatenating the repeater field name with the index and the subfield name. This allows as many items as necessary to be added. In key =&gt; value notation, the data collection looks like this:

- Repeater field: `$repeater => $count`
- First repeater subfield: `$first_subfield => $repeater . '_' . $index . '_' . $first_subfield`
- Second repeater subfield: `$second_subfield => $repeater . '_' . $index . '_' . $second_subfield` // etc

To use:

```
$postMeta = new Carawebs\DataAccessor\PostMetaData;

$carouselSubfields = [
    'image' => ['image_ID', 'full'], // denotes an image ID subfield, image size to return
    'description' => 'text' // subfield name, filter to apply
];

$carouselData = $postMeta->getRepeaterField('slider', $carouselSubfields);
```

Post-to-Post Relationships
--------------------------

[](#post-to-post-relationships)

The field type 'relationship' fetches an array of post IDs.

For an ACF relationship field, `$this->postMeta->getField('related_posts')` ...will return type based on that specified in the ACF field GUI.

Otherwise, you can pass in a field name and specify the 'relationship' type and an array of post IDs will be returned: `$this->postMeta->getField('related_posts', 'relationship')`.

If you're using ACF fields and the field 'return\_format' is set to return an object, a modified WordPress post object with additional properties representing the post featured image and permalink will be returned. This Object is filtered with `'carawebs/wp-metadata-accessor/post-object'`. To use this filter, add something like this within the active theme:

```
add_filter('carawebs/wp-metadata-accessor/post-object', function($obj, $id) {
    $obj->newProperty = someFunction($id);
    return $obj;
}, 1, 2);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

5

Last Release

3351d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4398535?v=4)[DavidEgan](/maintainers/DavidEgan)[@DavidEgan](https://github.com/DavidEgan)

---

Top Contributors

[![csknk](https://avatars.githubusercontent.com/u/5287744?v=4)](https://github.com/csknk "csknk (38 commits)")

### Embed Badge

![Health badge](/badges/carawebs-wp-metadata-accessor/health.svg)

```
[![Health](https://phpackages.com/badges/carawebs-wp-metadata-accessor/health.svg)](https://phpackages.com/packages/carawebs-wp-metadata-accessor)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
