How to change the output of gallery shortcode

If anybody is interested: I managed it to add a data attribute to the article thumbnail with following filter: function post_thumbnail_add_data_attribute( $input, $post_image_id ) { $caption = wptexturize(get_post(get_post_thumbnail_id())->post_excerpt); $substitute = is_home() ? “<img” : “<img data-description=\”” . $caption . “\””; return str_replace(“<img”, $substitute, $input); } add_filter(‘post_thumbnail_html’, ‘post_thumbnail_add_data_attribute’, 10, 3 ); For the gallery I followed … Read more

How to use/enable Pagination?

I realise that you say that you can’t enable paging of users, but if it’s a case of you don’t know how, you can pass ‘number’ and ‘offset’ in the args array. In your example to get page 2 of your users, set ‘number’ as ‘5’ and ‘offset’ as ‘5’. If using those variables is … Read more

Form Shortcode not saving data to WP database

Ok, for some reason it’s now working. Instead of hooking into ‘init’ I’ve used ‘the_post’ and the form shortcode does it’s job. I no longer have an issue with publishing a new post or the data not saving. Also, no “Cannot modify header information – headers already sent” error. The function function el_process_form(){ if( $_SERVER[‘REQUEST_METHOD’] … Read more

How to list users by custom field?

To fetch users with certain meta field, you can use WP_User_Query class. Check codex manual for it. So you can create a custom shortcode like this: add_shortcode( ‘listusers’, ‘wpse8170_listusers’ ); function wpse8170_listusers( $atts, $content=”” ) { $atts = shortcode_atts( array( ‘company’ => false ), $atts ); if ( empty( $atts[‘company’] ) ) return $content; $query … Read more

Get page content and execute shortcodes on a page

function get_page_func( $atts ){ extract(shortcode_atts( array( ‘title’ => ” ), $atts ) ); $page = get_page_by_title($title); $args = array( ‘include’ => $page->ID, ); $pages = get_pages($args); $html = $pages[0]->post_content; $html = do_shortcode($html); return $html; } add_shortcode( ‘get_page’, ‘get_page_func’ ); Use above code. Wherever you require shortcode to be executed just use the following line echo … Read more

Conditionally Loading JavaScript/CSS for Shortcodes

Based on my own experience, I’ve used a combination of method 1 & 2 – the architecture and footer scripts of 1, and the ‘look-ahead’ technique of 2. For the look-ahead though, I use regex in place of stripos; personal preference, faster, and can check for ‘malformed’ shortcode; preg_match( ‘#\[ *shortcode([^\]])*\]#i’, $content ); If you’re … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)