Jump to content

Finding post to post connection types


Mugan

Recommended Posts

Hi,

 

I have a series of post to post connections. In one function, the output is a list of the linked post to posts. Here is an example:

function countryJob(){

global $post;

    $echo = f_print(array(
        'data' => 'p2p',
        'type' => 'ul',
        'args' => array(
            'connection_type' => 'job_to_location',
            'post_type' => 'job',
            'connection_id' => $post->ID,
            'alternative' => '',
        ),
));

    echo '<div class="country-job-text">'.$echo.'</div>';

 

job, location and city are all post types that can be connected.

 

I want to create the same as above to create a list of the cites connected to a location (locations are the name for posts which are countries)

 

How do I discover the connection type and post type needed to create this output?

Link to comment
Share on other sites

well, the above function finds a list of all jobs connected to a location. it then creates that list as an echo.

I need to do the same with the cities connected to a location. So I need to change the 'connection_type' and 'post_type' args, and while that seems straightforward, it doesnt produce a result. I was wondering if connection_type or post_type needed to be specified elsewhere before they are named in this section of the code in order to pull the list of connected cities.

 

I'm very new, so any help understanding this is very useful. 

Link to comment
Share on other sites

the connections are specified in the wordpress backend, so all countries have a section in the backend that lets you choose which 'city' posts are connected to them.

What I then need to do is display these cities using a function that is looking up the country post you are on, and displays a list of the connected cities.

 

Sorry, I am very new to these types of function writing, and trying to understand some old code at the same time, so appreciate the help in understanding it.

Edited by Mugan
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.