Display gallery on top before content olatechproMarch 8, 20230 Views Is it possible to execute the gallery shortcode before any other content no matter where the shortcode is in the post HTML? Post Views: 0 Related postsGet rid of this Strict Standards warningWooCommerce: get_current_screen not working with multi languageCan’t login on WordPressForce HTTPS using .htaccess – stuck in redirect loopWordPress: Ajax not working to insert, query and result dataHow Can I pass an image file to wp_handle_upload?
function gallery_first( $content) { $expr = '/[gallery(.*?)]/i'; return preg_replace_callback( $expr, create_function('$matches', 'return do_shortcode($matches[0]);'), $content); } add_filter( 'the_content', 'gallery_first', 6); // prio 6 executes this function previous to all other filter functions Log in to Reply
function gallery_first( $content) { $expr = '/[gallery(.*?)]/i'; return (" [gallery] " . preg_replace( $expr, '', $content)); // deletes all existing gallery shortcodes } add_filter( 'the_content', 'gallery_first', 6); // level '6' executes this function previous to all other filter functions Log in to Reply
2 comments