Get raw image detail from post gallery?

A gallery is at heart just the set of attached posts, so… $post_id = 1; // set to your desired parent post $attachments = new WP_Query( array( ‘post_parent’ => $post_id, // post to which the gallery is attached ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, // ‘order’ => $order, // ‘orderby’ => $orderby … Read more

Custom single page based on which custom page template is selected

Yes it is possible using get_template_part(); Assuming that you use a standard single.php: <?php /* * Template name: template-blog-left * */ get_header(); ?> <div id=”left-sidebar”> <!– Here your left sidebar –> </div> <div id=”content”> <?php //This function will look for single.php file in your theme folder get_template_part( ‘single’ ); ?> </div> <?php get_footer(); ?>

Custom classes for attachments

Just add the following code in functions.php file of your theme which will add your custom added classes to images when you will insert it into post editor. function add_image_class($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ $classes = get_post_meta( $id, ‘classes’, true ); if ( preg_match(‘/<img.*? class=”.*?”>/’, $html) ) { $html = preg_replace(‘/(<img.*? … Read more

Create new folder and upload files to custom folder via wp_handle_upload

This isn’t a working example but should help, Use wp_upload_dir() to define the default uploads folder and append a username to it using wp_get_current_user. $wp_upload_dir = wp_upload_dir(); $user_folder = wp_get_current_user(); // The actual folder $custom_upload_folder= $wp_upload_dir[‘basedir’] . $user_folder->display_name; //make the dir mkdir($custom_upload_folder); You would need to employ security and code that checks for errors/user capabilities … Read more

permalink repeated

You sound like you are multisite which I don’t use but if this were a single site install I would tell you to remove blog/ from WP_SITEURL.

Strip shortcode from excerpt [duplicate]

A simple search in codex and you can set this! Anyway you can do something like : function remove_shortcode_from_excerpt($content) { $content = strip_shortcodes( $content ); return $content;//always return $content } add_filter(‘the_excerpt’, ‘remove_shortcode_from_excerpt’);