Get Post by Meta Value

An alternative to get_page_by_title() or get_page_by_path() when using Polylang to translate website content.

Get Post by Meta Value

We often use the excellent Polylang to translate website content, but by doing so we cannot reliable use functions such as get_page_by_title() or get_page_by_path() – because both the title and slug would change depending on which language version you are viewing ( not forgetting the unpredictable nature of using something that is so easy to edit to control template rendering ).

Instead we prefer to set a custom field for each post and in the the Polylang settings ensure that custom field data is not translatable.

Gist List
Get the Gist of things
Read the Comments
Open on github

Comments

No comments on this article yet.

Add a Comment

Your email address will not be published.

These HTML tags work: <a href=""> <code> <strong> <pre>


Connect:
OR

Our Services
Validate your ideas before diving in. Consultancy
Dig deep, audit your data, prepare for action Discovery
Get everything in shape to smooth the project path. Shaping
Let us help you realize your imagination Design
Rock-solid WordPress tools, built to last. Development
Without water, the garden will not grow. Support


Projects
Quinta de Sant’Ana, Portugal
Quinta de Sant’Ana, Portugal

Quinta de Sant'Ana overlooks the picturesque village of Gradil with its cobbled streets, white washed houses and hospitable inhabitants.


Projects: View All or
Releases
Willow
Willow

Willow is a Logic~less Template Engine built for WordPress. Willow plays nicely with ACF, is quick to learn and developer-focused.


Releases: View All or