Custom posts in different columns style

You need to use the offset paramater in WP_Query e.g. <?php $loop = new WP_Query( array( ‘post_type’ => ‘recentproject’, ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’) ); $counter=0; ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); $counter++; ?> <div class=”col-8 columns”> <?php edit_post_link(); // Always handy to have Edit Post Links available ?> <?php if ( … Read more

Plugins not working on AJAX requests

//This is the function that fails when calling the function via an AJAX request. $context[‘stories’] = apply_filters(‘xfwpint_get_slider_post_data’, $context[‘stories’]); When calling via ajax , you have to include file in your ajax action function, file in which you have defined your filter, so it gets called. For e.g. require_once(‘./my_file_containing_filter_function’);

Replace shortcode in substring

Check the $str with get_shortcode_regex(). If $match is returned, you need to parse $str with do_shortcode() and then return it, else false proceed. GetShortCodeRegEx DoShortCode UPDATE After Sleeping, and while researching to answer your comment, has_shortcode() should be replaced by get_shortcode_regex(), which I have done in my original above.

wp_mail file attachment not being placed in upload folder?

Attachments should always use the absolute filesystem path. Also to change the Content-Type of the email you should use the wp_mail_content_type filter. <?php function my_custom_email() { $to = ‘[email protected]’; $subject=”WordPress wp_mail”; $message=” <html> <body> <table rules=”all” style=”border-color: #666;” cellpadding=”10″> <tr>Hello WordPress</tr> </table> </body> </html> “; $attachments = array( WP_PLUGIN_DIR . ‘/my-plugin/uploads/sample_photo_01.jpg’ ); $headers[] = ‘From: … Read more

Remove echo from shortcode

‘echo’ statement will not work in shortcode function. shortcode function is just returning the variable; So your code will be like this: if(get_field(‘group’)) { $html=””; $html.= “<ul class=”sponsors”><h2>” , get_the_title() , “</h2>”; while(has_sub_field(‘group’)) { $attachment_id = get_sub_field(‘image’); $size=”sponsorimage”; $image = wp_get_attachment_image_src( $attachment_id, $size , false ); $link = get_sub_field(‘link’); $html.= “<li>”; $html.= “<a href=”” , … Read more