[wp-hackers] WP Custom Post Type as 'Taxonomy' for Other Custom Post Type

Otto otto at ottodestruct.com
Wed Mar 23 21:26:30 UTC 2011


It has nothing to do with how you register the post type. It has to do
with how you create the posts.

Attachment posts work in the same way. The attachment post has a
post_type of "attachment" and the post_parent is set to the post where
the attachment was uploaded (which has a post type of "post" or
"page").

When you do wp_insert_post to insert your custom post, you just set
the post_parent to the ID of the parent post item. Post type is
irrelevant to that.

-Otto



On Wed, Mar 23, 2011 at 4:12 PM, Alex Andrews <awgandrews at gmail.com> wrote:
> How would I go about implementing this when I register the post type.
>
> Thanks a lot.
>
> Alex
>
> On 16 March 2011 01:12, Dougal Campbell <dougal at gunters.org> wrote:
>> I'm not sure I understand why you say that. I still figured you'd have the
>> Artists and Releases as separate CPTs. There's nothing (technically)
>> stopping a post of type A from being the parent for posts of type B.
>>
>>
>> On Mar 15 2011 10:45 AM, Alex Andrews wrote:
>>>
>>> That sounds like a fair solution, but this would be roughly the same
>>> as having one custom post type - ie artists - what i want is two -
>>> artists and releases.
>>>
>>> Thanks a lot
>>>
>>> Alex
>>>
>>> On 12 March 2011 18:38, Dougal Campbell<dougal at gunters.org>  wrote:
>>>>
>>>> On Mar 12 2011 10:56 AM, Alex Andrews wrote:
>>>>>
>>>>> Hi guys,
>>>>>
>>>>> Thanks very much for this, these look great. But I wasn't really
>>>>> looking for a plugin solution to the problem but roughly how one would
>>>>> go about coding these kind of relationships where one has post type B
>>>>> (releases) being organised under post type A (artists) within a single
>>>>> plugin (or even in a functions .php file). So how to make one post
>>>>> type owned by another simply - linking two together in a way that is
>>>>> equivalent to a "artists has_many releases" in SQLish psuedo-code.
>>>>
>>>> Have you already considered just using the post_parent property in the
>>>> child
>>>> posts to point at the parent? You could just use get_children() to find
>>>> the
>>>> releases of an artist.
>>>>
>>>> --
>>>> Dougal Campbell<dougal at gunters.org>
>>>> http://dougal.gunters.org/
>>>> http://twitter.com/dougal
>>>> http://twitual.com/
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>
>>
>> --
>> Dougal Campbell <dougal.campbell at gmail.com>
>> http://dougal.gunters.org/ http://www.linkedin.com/in/dougal
>> http://twitter.com/dougal http://twitual.com/
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list