• Sorry if my question isn’t written in the right category or somehting. I haven’t found any topic about this. I’m not a developper and I am new to WordPress so my question might seems a little naive.

    I bougth a WP template at ThemeForest that has a gallery function/template. I wish to modify it’s behavior so that, instead of showing images from a category by clicling on the button related to it, the images from a particular category are shown automatically when the page loads. Currently, the images shown when the page is loaded seems to be selected randomly among all the existing categories. I want to get rid of the selecting option with the buttons and just show the images from a single category on a single gallery page. In fact, I would need three independent gallery pages each showing it’s own category images. Actually, I need to simplify the gallery jQuery function I guess. I thought I might need to duplicate the _gallery.php template so that I could have three different galleries but I am not sure. Here is the gallery template code that generates the gallery and below is a link to the theme I bougth:

    <!-- GALLERY -->
            <div class="wrapper">
    
                                <?php
                                  global $wpdb;
                                  $post_type_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'pt_gallery' AND post_status = 'publish'");
                                  if(!empty ($post_type_ids )){
                                    $post_type_cats = wp_get_object_terms( $post_type_ids, 'category',array('fields' => 'ids') );
                                    if($post_type_cats){
                                      $post_type_cats = array_unique($post_type_cats);
                                      $allcat = implode(',',$post_type_cats);
                                    }
                                  }
                                  $include_category = null;
                                ?>
    
                 <div class="speakers-filter left">
                        <h3>Quelques photos de l'&eacute;v&eacute;nement :</h3>
    
                    <div class="page-portfolio-categories left">
                        <div class="bg-portfolio-categories left">
                            <div class="portfolio-categories left">
                                <ul>
    
                                    <div class="color-buttons left">
                                        <li class="paragraphp cat_cell_active cat_cell" rev="<?php echo $allcat?>">
                                            <div class="small-black">
                                                <div class="small-black-center cat_cell_active left cat_cell"><a href="#"><?php _e('Tout', 'eventor')?></a></div>
                                            </div>
                                        </li>
                                    </div>
    
                                  <?php
                                if(!empty ($post_type_ids )){
                                     foreach ($post_type_cats as $category_list) {
                                        $cat = 	$category_list.",";
                                        $include_category = $include_category.$cat;
                                        $cat_name = get_cat_name($category_list)
                                    ?>
    
                                    <div class="color-buttons left">
                                        <li rev="<?php echo $category_list?>" class="cat_cell">
                                            <div class="small-black">
                                                <div class="small-black-center left"><a href="#"><?php echo $cat_name?></a></div>
                                            </div>
                                        </li>
                                    </div>
    
                                    <?php } }?>
                                </ul>
                            </div><!--/portfolio-categories-->
                        </div><!--/bg-portfolio-categories-->
                    </div><!--/page-portfolio-categories-->
    
                </div><!-- /speakers-filter -->
    
                                    <div class="portfolio-loader" id="portfolio-loader" style="position: relative;top: 300px;"></div>
    
                <div class="portfolio-content left">
    
                            <script type="text/javascript">
                                jQuery(document).ready(function(){
                                    jQuery('.cat_cell_active').click();
                                });
                            </script>
    
                            <script type="text/javascript">
                                jQuery('.cat_cell').live('click',
                                function () {
                                    var id = jQuery(this).attr('rev');
                                    jQuery('.cat_cell').removeClass('cat_cell_active');
                                    jQuery(this).addClass('cat_cell_active');
                                    jQuery('.ajax_holder').animate({opacity:0},500,function(){
                                        jQuery('.portfolio-loader').show().animate({opacity:0},0).animate({opacity:1},500,function(){
                                            var randomnumber=Math.floor(Math.random()*100000000);
                                            var postAjaxURL = "<?php echo get_template_directory_uri() ?>/_galleryajax.php?id="+id;
    
                                            jQuery('.ajax_holder').load(postAjaxURL, {rand: randomnumber},function(){
                                                jQuery('.portfolio-loader').animate({opacity:0},500).hide();
                                            });
                                        });
                                    });
                                    return false;
                                });
                            </script>
    
    				<div class="ajax_holder"></div><!--AJAX Holder-->
    
                     <?php

    The theme. Just take a look at the gallery section:

    http://themeforest.net/item/eventor-event-management-wordpress-theme/full_screen_preview/2437242

    Thanks in advance for helping!!!

The topic ‘Modify WP theme's gallery behavior’ is closed to new replies.