Support

Account

Forum Replies Created

  • John,

    Thanks for the follow up!

    Do you know if “the next release” is going to be 4.6 or 4.5.1?

  • James,

    It was actually quite easy, since the column is there purely for reference (no need to filter etc.). Perhaps the code is useful for someone else! 🙂

    function build_listing_column_head( $columns, $post_type = 'listing' ) {
    
    	if( ! is_admin() ) {
    		return;
    	}
    
    	if( $post_type == get_post_type() ) {
    		$columns['relation'] = esc_html__( 'Relation', 'lystr' );
    	}
    
    	return $columns;
    
    }
    
    add_action( 'manage_listing_posts_columns', 'build_listing_column_head', 10, 2 );
    
    function build_listing_column_content( $column, $post_id ) {
    
    	global $post;
    
    	if( ! is_admin() || 'relation' !== $column ) {
    		return;
    	}
    
    	$relation = get_field( 'relationship', $post->ID, false );
    
    	if( ! empty( $relation ) ) {
    
    		$id = implode( ',', $relation );
    		$title = get_the_title( $id );
    		echo $title;
    
    	}
    
    }

    Thanks for your help! 🙂

  • James,

    There would be no need to update anything, i’d just like to list the value of my relationship field next to the author, categories, tags etc.

    Sometimes i want to just know what relationship a post has, i’d have to edit it to see it .. would be neat if there was a admin column for it! 🙂

  • Ok awesome, i’ll keep an eye on this thread! 🙂

    About the querying, i figured so much but wondered if there might have been a shortcut or something 🙂

  • John, i think i read somewhere they decided it was best for the commentform textarea to appear on top – pretty recently (im thinking since 4.4).

    Moving the textarea down will place the fields between name/email/url and textarea .. it’s not that pretty. Is there no way to just stick them on top regardless?

    Also did you read my edit? 🙂

    if i add fields to the commentform, how would i query posts by the value in these fields?

    Thanks for your help.

  • James, i managed to get it working!

    Thanks for all your help.

    I’ve got one additional question though, it’s relationship field related:

    Would it be possible (and if yes how) to create an admin column for the relationship field? So the relationship will be visible on my custom post type overview page?

  • This reply has been marked as private.
  • James, thanks for your reply.

    I’ve managed to get it working but i will definetly give your solution a try (and see which one runs better).

    What i did was: i created a new loop with all listings that are in the category “restaurant”. Based on the results i created an array of ID’s.

    In the main loop for the archive page i used the array i just created in the ‘post__in’ query variable and voila.

    Would you say this consumes a lot of resources?

    I’m trying to go about this as simple and smooth as possible so i’m definetly want to go with the best-practice.

  • Hi, thanks for your reply.

    I’ll try and explain my situation, for example: i have 2 post types “areas” and “listings”. All listings can be assigned to 1 area (via the relationship field). Each listing can have 1 or more categories.

    Let’s say i have 3 areas: Amsterdam, New York and Sydney.
    Let’s say i have 3 listings: Listing 1, Listing 2 and Listing 3.
    Let’s say Listing 1 is assigned to Amsterdam, Listing 2 is assigned to New York and Listing 3 is assigned to Sydney.
    Let’s say both Listing 1 and Listing 3 have a category called “restaurant”.

    What i want to be able to do is create an archive of areas and query those archives by the category assigned to the listings.

    So normally the archive page for areas would show Amsterdam, New York and Sydney. With the query i want to built i want it to only show Amsterdam and Sydney because these areas are related to the listings that have the “restaurant” category.

    It’s a bit complex and i actually nearly there. However i’m not sure if im going about this the right way.

    On a side note my relationship field returns an array that looks like:

    Array ( [0] => Array ( [0] => 177 ) [1] => [2] => Array ( [0] => 164 ) )

    While for it to become useful it should look like:

    Array ( [0] => 177 [1] => 174 )

    Thanks!

  • That looks like it should work, going to test it out and report back! Thanks a lot! 🙂

Viewing 11 posts - 1 through 11 (of 11 total)