Skip Navigation

[Closed] Can you create a relationship between a post type and pages?

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2288173

Tell us what you are trying to do?
We've created a post type to create CTA blocks that will display on the bottom of each page and then created a relationship between that post type and pages because we want to be able to select unique CTA blocks on different pages. Problem is, it doesn't seem to work. When we have relationships between two post types, we have no issue but connecting it to a page may require different code.
Is there any documentation that you are following?
None beyond basics of relationships in Toolset.
Is there a similar example that we can see?
The footer of our site has a loop that should be pulling a CTA block but is currently not pulling any data. Not erroring out, but not pulling or displaying data either. Here's the beginning of the loop we're using...

<?php
// Insert code block for CTA Block
$blocks = toolset_get_related_posts( get_the_ID(), 'page-cta-block', array(
'query_by_role' => 'child',
'limit' => 25,
'post_status' => 'publish',
'return' => 'post_object'
) );

foreach ( $blocks as $block ) {
// CTA Blocks are returned as WP_Post objects
$ID = $block->ID;
$img = get_the_post_thumbnail_url($ID);
$meta = get_post_meta($ID);
$the_content = $block->post_content;
$the_title = $block->post_title;
$cta_block_background= $meta['wpcf-cta-block-background'][0];
$cta_block_headline_color= $meta['wpcf-cta-block-headline-color'][0];
$cta_block_button_link= $meta['wpcf-cta-block-button-link'][0];
$cta_block_button_color= $meta['wpcf-cta-block-button-color'][0];
$cta_block_button_text= $meta['wpcf-cta-block-button-text'][0];
?>

What is the link to your site?
hidden link

#2288337

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details and tell me where exactly you have added the code you shared and let me see whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Can you create a relationship between a post type and pages?’ is closed to new replies.