Skip Navigation

[Resolved] Link to Parent Relationship in the grid

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display the title of a parent post in The Grid.

Solution: The standard post relationship shortcodes do not work well in The Grid. Try this custom shortcode instead:

add_shortcode( 'ts-get-parent-artist', 'ts_get_parent_artist_func');
function ts_get_parent_artist_func( $atts, $content ) {
  $a = shortcode_atts( array(
      'child' => '0',
      'type' => 'artist',
  ), $atts );
  $parent = toolset_get_related_post( $a['child'], 'artist-release' );
 
  return get_the_title($parent);
}

Then add this to The Grid:

[ts-get-parent-artist child="#post_ID#"]

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

This support ticket is created 5 years, 5 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.

Our next available supporter will start replying to tickets in about 0.30 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 16 replies, has 2 voices.

Last updated by chrisC-25 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1146055

Hi

I want to be able to show the name of the parent of a post in a grid. Similar to this post
https://toolset.com/forums/topic/link-to-parent-relationship-not-working-in-grid/

But with a different plugin. The plugin I want to use was working in the old version of Toolset, see solution here:
https://toolset.com/forums/topic/i-want-to-pull-metadata-into-a-grid-plugin-pulling-from-parent-relationship-wa/

It now does not work with updated toolset.

Info on the plugin can be found here:
hidden link

Thanks

#1146095

In the updated Toolset post relationships system, information about related posts is no longer stored in postmeta. So the approach used before isn't possible with new post relationships. We might be able to figure out a different approach.
1. What are the slugs of the two post types?
2. What is the post relationship slug? You can find this in Toolset > Relationships.
3. Which post type is the parent and which post type is the child?

#1146599

Hi Christian,

The slugs are:
artist
release

Relationship slug is:
artist-release

It is a many to many relationship but I guess the artist is the parent.

Thanks

#1146665

Try this alternate syntax, designed to work in the new post relationships system:

[wpv-post-title item="@artist-release.parent"]
#1146764

Okay so in the skin editor of the grid when I add that shortcode in the preview in The Grid plugin it comes up with the same artist for every release, which is of course not right. But when I look at it on a page it shows no artist at all.

#1147288

May I log in and take a closer look? I'm not really familiar with The Grid.

#1147328

How can I access the ID of the current post in a skin? Is there a shortcode or something? The Grid's documentation doesn't have a list of variables or shortcodes, and I don't see any information directly related to this.

#1147344

Hi

The actual setup for how this grid works is here:
hidden link
Gris is called: New Release RECORDS Page Grid

What I sent before was the custom skin that I made where I added the shortcode.

The grid pulls in the custom posts from Releases. You can see that in the Source tab inside the grid settings from link above.

Chris

#1147409

This doesn't help, sorry. I need to know how to access the ID of the current post, while in the skin editor area.

#1147431

Okay, sorry the support is hard to find. I did find this in their developer notes:

// get the item ID
$tg_el->get_item_ID();

Does that help?

#1147432

Here is link to that developer section

hidden link

#1147440

I need a shortcode or placeholder or some code I can insert directly in the skin editor to get the ID of the current post in the Grid. If it's important to display related post information in the grid, I suggest you reach out to the developers or support team for The Grid to get a definite answer to this question:
How can I get the ID of the current grid post in a grid skin editor?

#1147442

Okay, I contacted them, I will let you know what they say.
Thanks

#1147443

Well that was quick here is what they said:
My content #post_ID#

#1147444

Sorry forgot this

You can use text/HTML element add the post id like this:
My content #post_ID#

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.