Use appearance of portfolio in archives and categories

Writer, blogging theme for writers and authors | Support forum.
GK User
Fri Mar 27, 2015 12:58 am
Hi!

I would like to use the appearance of the portfolio in the archives and categories.
I duplicated and renamed the file template.portfolio.php to archive.php and category.php but has failed.
What else should I do?

Thanks
User avatar
Expert Boarder

GK User
Fri Mar 27, 2015 8:15 am
Hi,

Unfortunately it's not enough, because template.portfolio uses custom loop, generally it requires more modifications.
I.e. you should use default loop, instead of:
Code: Select all
<?php while ( $loop_global->have_posts() ) : $loop_global->the_post(); ?>

use:
Code: Select all
 <?php while ( have_posts() ) : the_post(); ?>
User avatar
Moderator

GK User
Fri Mar 27, 2015 1:20 pm
Hi Piotr!

I did what you told me, but still not working.
The charging icon of each article there appears, but don't loaded the articles.
Anything else that should be made?

Thanks
User avatar
Expert Boarder

GK User
Fri Mar 27, 2015 9:22 pm
I've provided only example, you have to change the entire loop, generally you should use the category.php as a starting point and change only the content inside the loop, I'll check the files when I find some time.
User avatar
Moderator

GK User
Mon Mar 30, 2015 11:56 am
Hi!


Then what you say, I would have to take the category.php and copy the structure of the loop template.portfolio.php creating a new loop in category.php. That's right?

And as I give the styles de template.portfolio.php?

It would be great if you could check the files.


Thanks.
User avatar
Expert Boarder

GK User
Tue Mar 31, 2015 8:45 am
please check the attached category.php file, you have to also load portfolio.js file on this page.
Please check functions.php file and writer_scripts function, /js/portfolio.js is loaded only under this condition:
Code: Select all
if (is_page_template( 'template.portfolio.php' ) || is_page_template( 'template.polaroid.php' )) {
..
}

You have to remove this condition or add is_category() conditional tag;
Probably you'll have to adjust the css a little and you'll have a problem with pagination, but this issue was beyond our technical support in general, so you have to fix the rest by yourself.
User avatar
Moderator

GK User
Tue Mar 31, 2015 8:51 am
Oh! Thanks Piotr!

When I got to the office I test :)
User avatar
Expert Boarder

GK User
Tue Mar 31, 2015 12:50 pm
Porfolio model has pagination? I thought it was an infinite scroll.

Thanks.
User avatar
Expert Boarder

GK User
Tue Mar 31, 2015 1:40 pm
Hi!

I created a new childtheme/funtions.php in which I copied the function writer_scripts and I added:
Code: Select all
is_tax('jetpack-portfolio-type')

Now load portfolio.js :D

But it has the appearance of Polaroid Style. How can I do that looks "normal" portfolio?

Only see 2 columns of projects, to change this is pure CSS or JS also comes into play? (Portfolio.js)

I would have to include elements of template.portfolio.php within my new taxonomy-jetpack-portfolio-type.php?

Thanks again! :)
User avatar
Expert Boarder

GK User
Tue Mar 31, 2015 6:10 pm
Hi!

It works and looks perfect! :D :D :D
The loop of the file that you had passed me was copied your model of Polaroid, the without-overlay class was the problem.
I replace without-overlay for with-overlay, and it looks like portfolio.

To make everything look good, I had to load the options portfolio

Code: Select all
// get the options
$cat_slug = get_theme_mod('writer_portfolio_cat_slug', '');
$articles_amount = get_theme_mod('writer_portfolio_articles', '20');
$columns = get_theme_mod('writer_portfolio_columns', '5');
$columns2 = get_theme_mod('writer_portfolio_columns2', '4');
$columns3 = get_theme_mod('writer_portfolio_columns3', '3');
$columns4 = get_theme_mod('writer_portfolio_columns4', '2');
$columns5 = get_theme_mod('writer_portfolio_columns5', '1');


I haven't had to change anything more :)

In case anyone needs it, in the end the entire code has been well

Code: Select all
<?php
/**
 * The template for displaying Category pages PORTFOLIO
 *
 */

// get the options
$cat_slug = get_theme_mod('writer_portfolio_cat_slug', '');
$articles_amount = get_theme_mod('writer_portfolio_articles', '20');
$columns = get_theme_mod('writer_portfolio_columns', '5');
$columns2 = get_theme_mod('writer_portfolio_columns2', '4');
$columns3 = get_theme_mod('writer_portfolio_columns3', '3');
$columns4 = get_theme_mod('writer_portfolio_columns4', '2');
$columns5 = get_theme_mod('writer_portfolio_columns5', '1');

// amount of one column entries
$one_column_entries = get_theme_mod('writer_one_column_entries', '2');

get_header(); ?>

   <div id="gk-content" class="hfeed site fullwidth">
      <?php if (is_active_sidebar('top')) : ?>
         <?php do_action('writer_before_top'); ?>
         <div id="gk-top" role="complementary">
            <div class="widget-area gk-3-cols" data-cols="<?php echo GK_Utils::count_sidebar_widgets('top', 3); ?>">
               <?php dynamic_sidebar('top'); ?>
            </div>
         </div>
         <?php do_action('writer_after_top'); ?>
      <?php endif; ?>

      <?php if ( have_posts() ) : ?>
         <div id="content" class="site-content" role="main">
            <?php do_action('writer_before_content'); ?>
            <div class="portfolio-grid with-overlay"
               data-cols="<?php echo $columns; ?>"
               data-small-desktop-cols="<?php echo $columns2; ?>"
               data-tablet-cols="<?php echo $columns3; ?>"
               data-small-tablet-cols="<?php echo $columns4; ?>"
               data-mobile-cols="<?php echo $columns5; ?>"
            >
               <?php while ( have_posts() ) : the_post(); ?>

                  <div class="figure loading">

                     <?php if ( has_post_thumbnail() ) : ?>
                        <?php
                           $data_popup = 'false';
                           $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), apply_filters('writer_portfolio_thumb_size','portfolio-thumb'));
                           $thumb_full = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');

                           $image_url = $thumb[0];
                           $img_url = get_permalink();
                           if (get_theme_mod('writer_portfolio_enable_popup', '1') == '1') {
                              $img_url = $thumb_full[0];
                              $data_popup = 'true';
                           }
                           $title_length = strlen(get_the_title());
                        ?>
                        <a href="<?php the_permalink(); ?>" class="image-resource" data-url="<?php echo $image_url; ?>">
                           <img src="#" class="helper-image" alt=""/>
                        </a>
                     <?php endif; ?>

                     <div class="figcaption" data-popup="<?php echo $data_popup; ?>" data-popup-url="<?php echo $img_url; ?>">
                        <div>
                           <?php if (get_theme_mod('writer_portfolio_show_title', '1') == '1') : ?>
                              <h3>
                                 <a href="<?php the_permalink(); ?>" rel="bookmark" class="inverse">
                                    <?php echo substr(get_the_title(), 0, get_theme_mod('writer_portfolio_title_limit', '40')) ; ?>
                                    <?php if ($title_length > get_theme_mod('writer_portfolio_title_limit', '40') ) {
                                       echo '...';
                                    } ?>
                                 </a>
                              </h3>
                           <?php endif; ?>
                           <span>
                              <?php if (get_theme_mod('writer_portfolio_show_date', '1') == '1') : ?>
                                 <?php
                                    if ('post' == get_post_type() ) {
                                       $date_format = esc_html(get_the_date(get_theme_mod('writer_portfolio_date_format', 'j.m.Y')));
                                       echo sprintf('<time class="entry-date" datetime="'. esc_attr(get_the_date('c')) . '">'. $date_format . '</time>');
                                    }
                                 ?>
                              <?php endif; ?>

                              <?php if (get_theme_mod('writer_portfolio_show_author', '1') == '1') :
                                 printf( '<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a>',
                                    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                                    esc_attr( sprintf( __( 'View all posts by %s', 'writer' ), get_the_author() ) ),
                                    get_the_author()
                                 );
                              endif; ?>
                           </span>
                        </div>
                     </div>

                  </div><!-- #post -->

               <?php endwhile; ?>
            </div>
         <?php do_action('writer_after_content'); ?>

         </div><!-- #content -->
      <?php endif; ?>

      <?php if (is_active_sidebar('bottom')) : ?>
      <?php do_action('writer_before_bottom'); ?>
      <div id="gk-bottom" role="complementary">
         <div class="widget-area gk-3-cols" data-cols="<?php echo GK_Utils::count_sidebar_widgets('bottom', 3); ?>">
            <?php dynamic_sidebar('bottom'); ?>
         </div>
      </div>
      <?php do_action('writer_after_bottom'); ?>
      <?php endif; ?>
   </div><!-- #gk-content -->

<?php get_footer(); ?>


Thanks for all Piotr! :D
User avatar
Expert Boarder


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.