Home Forums Plugin Support WP User Frontend Pro Insert [gallery] shortcode on form

This topic is: resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Gaby 4 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2923

    ggsalas
    Participant
    Post count: 108

    I would like to insert the gallery shortcode to show images of post. The problem is that  I need insert the shortcode automatically, without user typing.

    Thanks

    #2928

    Tareq Hasan
    Keymaster
    Post count: 2831

    Inserting this snippet to your theme functions.php will append the gallery shortcode to your posts automatically when creating a new post.

    [php]
    function wpufe_append_gallery( $postarr ) {
    $postarr[‘post_content'] .= "[gallery]";

    return $postarr;
    }

    add_filter( ‘wpuf_add_post_args', ‘wpufe_append_gallery' );
    [/php]

    #2981

    ggsalas
    Participant
    Post count: 108

    Works perfect. Thanks

    #5156

    ggsalas
    Participant
    Post count: 108

    Can I insert the “gallery” shortcode ONLY on the posts with gallery format?

    Thanks

    #5170

    Tareq Hasan
    Keymaster
    Post count: 2831

    The existing code can be modified like this:

    [php]
    function wpufe_append_gallery( $postarr, $form_id, $settings ) {
    if ( $settings[‘post_format'] == ‘gallery' ) {
    $postarr[‘post_content'] .= "[gallery]";
    }

    return $postarr;
    }

    add_filter( ‘wpuf_add_post_args', ‘wpufe_append_gallery', 10, 3 );
    [/php]

    #33746

    Gaby
    Member
    Post count: 1

    How would I put the images in to a slider?

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

The topic ‘Insert [gallery] shortcode on form’ is closed to new replies.