Repeatable Group – Set-up and Import data via WP All Import
Started by: janetA-2
in: Toolset Professional Support
Quick solution available
Problem: I have an RFG set up on my site, and I would like to import content using a CSV import tool.
Solution: You should import each row of the RFG as though it is a new post, where the post type slug is identical to the RFG slug. The column format for the CSV file is dependent upon the CSV import tool you are using, but usually must include a column for specifying a parent post title or GUID with the column header format _toolset_associations_{RFG slug}. There should also probably be columns for post title, post author, and any custom fields you want to import for each row of the RFG. See the examples provided in this ticket for more information, and refer to the documentation for your preferred CSV import tool.
Relevant Documentation:
https://toolset.com/course-lesson/importing-content-from-csv-with-post-relationships/
3
6
4 years, 10 months ago
janetA-2
Alt Text Output for Images from Custom Field…
Started by: shawnW-3
in: Toolset Professional Support
Quick solution available
Problem:
The user would like to display image from a custom field and generate its caption, alt text, and description from the Media Library.
Solution:
This is not available out of the box. It needs a custom shortcode to be implemented:
function media_info_func( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'field' => '',
'info' => '',
),
$atts
);
global $post, $wpdb;
$field = $atts['field'];
$info = $atts['info'];
$image_url = get_post_meta( $post->ID, $field );
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
$attachment_id = $attachment[0];
if ( $field && $info ) {
switch($info) {
case 'id':
return $attachment_id;
break;
case 'title':
// return return ("[wpv-post-title item='$attachment_id']");
return wpv_do_shortcode("[wpv-post-title item='$attachment_id']");
break;
case 'alt':
// return ("[wpv-post-field name='_wp_attachment_image_alt' item='$attachment_id']");
return do_shortcode("[wpv-post-field name='_wp_attachment_image_alt' item='$attachment_id']");
break;
case 'caption':
// return ("[wpv-post-excerpt output='raw' item='$attachment_id']");
return do_shortcode("[wpv-post-excerpt output='raw' item='$attachment_id']");
break;
case 'description':
// return ("[wpv-post-body view_template='None' item='$attachment_id']");
return do_shortcode("[wpv-post-body view_template='None' item='$attachment_id' output='raw']");
break;
}
}
}
add_shortcode( 'media-info', 'media_info_func' );
The shortcode can be used as follow:
Image ID: [media-info field='wpcf-single-image' info='id']
Title: [media-info field='wpcf-single-image' info='title']
Alt text: [media-info field='wpcf-single-image' info='alt']
Caption: [media-info field='wpcf-single-image' info='caption']
Description: [media-info field='wpcf-single-image' info='description']
2
5
4 years, 11 months ago
shawnW-3