Gallery Images could not be shown
Gallery Images could not be shown
Gallery Images could not be shown
Create page template with this code : $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1 ); $query = new WP_Query( $args); if($query->have_posts()){ //check if found any attachment while($query->have_posts()){ //loop $query->the_post(); //you can add your code here } }else{ // if found NO posts }
make sure you’ve tried… flushing any caching plugins you might be running, as well as server and/or browser caches. deactivating all plugins (yes, all) to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s). If you can’t get into your admin dashboard, try … Read more
If you know the taxonomy name the plugin uses, you should be able to use the_terms pretty easily. You could basically plop this in between <?php foreach( $images as $image ): ?> and <?php endforeach; ?> where you want the terms to be displayed: <?php the_terms($image->ID, ‘YOUR_TAXONOMY_NAME’); ?> If you want to get fancy, you … Read more
Create a Gallery and update Post Parent of Attachment Images
The gallery is a shortcode, so you will need to parse the shortcode to grab the image referenced therein: function pull_image_from_gallery(){ global $post; $pattern = get_shortcode_regex(); preg_match_all( “https://wordpress.stackexchange.com/”. $pattern .’/s’, $post->post_content, $matches ); foreach ($matches[2] as $k=>$v) { if (‘gallery’ == $v) { $atts = shortcode_parse_atts($matches[3][$k]); if (!empty($atts[‘ids’])) { $ids = explode(‘,’,$atts[‘ids’]); $first = $ids[0]; … Read more
Making a archive gallery page for a custom post type which already has an archive page
To determine the best filter to use, you have to determine what those pages are. Is is_page() true? Use the page_template filter. Is is_post_type_archive() true? Use the archive_template filter. All of the query type-specific template filters are listed here. You can also use the generic template_include, which fires for all types. Within any of these … Read more
If you want max_num_pages, you need to use WP_Query instead of get_posts. You can then use $your_query_object->max_num_pages in your code. offset and paged don’t work together, because both of them ultimately set LIMIT in the MySQL query. offset query parameter will always override paged. If you want to offset the results, you need to do … Read more
Edit is changing my custom’s post type parent id