Show entries as WordPress posts
Turn on Show in WordPress for a model. Each published entry then gets a WordPress post, which SEO plugins, sitemaps, menus and site search can read.
Before you start
- You need the Administrator role to change a model.
- The model must be a node model that is not retired.
Show a model in WordPress
- Select Models.
- Open the model.
- Select Advanced.
- In the WordPress card, turn on Show in WordPress.
- Select Save changes.
Result: Each published entry gets a WordPress post. The post type is mx_ followed by the model's type name, up to 20 characters in total. For example, the book model uses mx_book.
Show in WordPress does not need Morphic Pro.
What happens to the posts
- If the model has a publishing field, an entry gets a post only while that field is set to
published. Without a publishing field, an entry gets a post until it is deleted. - When an entry is unpublished or deleted, its post is deleted.
- A link to the post uses the entry's page address when Morphic has one for the entry.
get_post_meta()on a post returns Morphic values for keys that do not start with an underscore, and for_thumbnail_id.
Query Morphic entries with WP_Query
Add a morphic argument to a WP_Query. The argument needs the type of the model. It can also take where, limit and order. Morphic then answers the query with its entries.
$q = new WP_Query(['post_type' => 'mx_book', 'morphic' => ['type' => 'book', 'where' => ['genre' => 'science'], 'limit' => 20]]);
Result: The query returns book entries whose genre is science. Morphic returns at most 100 entries per query. If Morphic refuses the query, for example because no index answers the where fields, WordPress runs its own query.
Use get_field() with Morphic Pro
With Morphic Pro licensed and the ACF plugin not active, Morphic defines get_field(), the_field(), have_rows() and the_row(). Theme code that uses these functions then reads Morphic values. Without Morphic Pro, Morphic does not define them.