Adding image upload in tag section – WordPress plugin development

I handle this with AJAX. Bellow is the solution. HTML: <label><?php _e( ‘Featured Image’, EG360_TEXT_DOMAIN ); ?></label> <div id=”eg360_tax_image” style=”float: left; margin-right: 10px;”> <img src=”<?php echo esc_url( eg360_placeholder_image() ); ?>” width=”60px” height=”60px”/> </div> <div style=”line-height: 60px;”> <input type=”hidden” id=”eg360_tax_image_id” name=”eg360_tax_image_id”/> <button type=”button” class=”upload_image_button button”><?php _e( ‘Upload/Add image’, EG360_TEXT_DOMAIN ); ?></button> <button type=”button” class=”remove_image_button button”><?php _e( … Read more

wp.media gallery collection sometimes undefined

So i finally figured it out, the gallery switches modes sometimes, even without clicking anything (not completely sure what actually happens, I have no idea about Backbone tbh.) Here is what now works for me: if(wp.media.frame.content.get(‘gallery’).collection) { wp.media.frame.content.get(‘gallery’).collection.add(formatted); } else { wp.media.frame.controller.content.get(‘gallery’).collection.add(formatted); } The else-line won’t work when initially loading of media library, so I … Read more

Get next and prev item from custom WP_Query and Custom Post Type

Are you maybe looking for something like this? /** * Outputs blog / archive pagination * */ function my_pagination(){ global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1): $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘current’ => $current_page, ‘total’ => $total_pages, ‘prev_text’ => ‘Prev’, ‘next_text’ => ‘Next’, ‘type’ => ‘list’ )); endif; } Then include it … Read more