changelog

Live Example

[own_shortcode1] add_action( 'voxel/app-events/post-types/events/post:submitted', 'update_events_logo' ); add_action( 'voxel/app-events/post-types/events/post:updated', 'update_events_logo' ); function update_events_logo( $event ) { $post = $event->post; // Check if it's a jobs post if ( $post->post_type->get_key() !== 'events' ) { return; } // Get the related post ID from the post-relation field $relation_id = $post->get_field('post-relation')->get_value()[0] ?? null; if ( $relation_id && is_numeric( $relation_id ) ) { // Get the logo attachment ID from the related post $logo_id = get_post_meta( $relation_id, 'logo', true ); if ( $logo_id && is_numeric( $logo_id ) ) { // Update the events post's logo with the attachment ID update_post_meta( $post->get_id(), 'logo', (int) $logo_id ); } } }

PHP

add_action( 'voxel/app-events/post-types/events/post:submitted', 'update_events_logo' );
add_action( 'voxel/app-events/post-types/events/post:updated', 'update_events_logo' );


function update_events_logo( $event ) {
$post = $event->post;


// Check if it's a jobs post
if ( $post->post_type->get_key() !== 'events' ) {
return;
}


// Get the related post ID from the post-relation field
$relation_id = $post->get_field('post-relation')->get_value()[0] ?? null;


if ( $relation_id && is_numeric( $relation_id ) ) {
// Get the logo attachment ID from the related post
$logo_id = get_post_meta( $relation_id, 'logo', true );


if ( $logo_id && is_numeric( $logo_id ) ) {
// Update the events post's logo with the attachment ID
update_post_meta( $post->get_id(), 'logo', (int) $logo_id );
}
}
}

Automatically get logo from related post

The Mission

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

There are no results matching your search

AI Assistant