I’m not extremely familiar with the export module so what I’m suggesting may not be a fit for your needs but the answer to your stated question of “Will a post object’s post_name
always be equal to the 'path'
on non-hierarchal custom post types? (using get_page_by_path()
function)” is “it depends.” 🙂
More specifically, the path of a post type can be filtered using the 'post_type_link'
hook, so it won’t always be equal to post_name
but interesting the get_page_by_path()
function does not worry itself with that hook. So if a site uses a plugin that modifies the custom post type’s path using the 'post_type_link'
hook then there is a good chance they won’t sync up. Even so, since get_page_by_path()
ignores the hook it would probably work for your needs.
That said, I wouldn’t recommend using the page_name
to link the two. I’ve tried similar in the past and down that path lies madness. It’s simply too easy for another plugin to change the page_name
and break your associations. I’ve learned from many hard knocks that if you care about robustness then you should always store your associations (aka foreign keys) using IDs and (almost?) never human-readable strings.
Better to use the post_parent
field in your slider to store the layout’s post_id
(but only if each slider is unique to a layout) or to store the layout’s post_id
in wp_postmeta
for a slider with a meta_key
of (something like) '_layout_id'
, a meta_value
of the layout’s post_id
, and post_id
equal to the post ID of the slider.
Would either of those two approaches work?