Topic: Category.php file can't be found in my theme files in order to generic shortcode | WP Masonry Layout

Category.php file can't be found in my theme files in order to generic shortcode

Home Forums Pro Version Category.php file can't be found in my theme files in order to generic shortcode

This topic contains 4 replies, has 2 voices, and was last updated by  Masonry Guy 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13272 Reply

    Theodule Zeraga
    Participant

    As described in the documentation, for category template to be displayed in a Masonry layout, we need first to edit the category.php file in Editor of the installed theme. The problem is I can’t find this file in my Editor when pointing on my current theme. The file does exist under the Twenty Fourteen theme (not in use). Should I use this file? Or is there an equivalent in my current theme files?
    Many thanks for your help.

    #13273 Reply

    Theodule Zeraga
    Participant

    To elaborate on this, I actually choose to use a generic shortcode because in the standard shortcode when I select a certain category, it only shows one post in that category. Is that normal? If I can find a solution to this I won’t need to alter the theme file.
    Many thanks.

    #13275 Reply

    Masonry Guy
    Keymaster

    Hi,

    May be your category.php is handle by other template. There must be archive.php or index.php.

    In that case, you can take a copy of archive.php/index.php (Please use archive.php if it exists) and rename it to category.php. And there you can replace the loop with the shortcode.

    Hope this helps.

    Thanks

    #13277 Reply

    Theodule Zeraga
    Participant

    Hi,

    Thanks for your answer. I’m not really a IT guy. So my questions will probably be trivial.
    I do have archive.php and index.php. When you say a copy, do you mean that I need to go to file manager make a copy then rename it?
    Plus I look through the archive file, but can’t tell where the loop is located. There is no as in your video explicit description like ”start the loop”. Can you have a look at the archive.php content below?
    Finally I go back to my previous question, why it isn’t possible in the first place (standard shortcode) to have all the posts when we select a certain category?

    Here is the archive.php content:

    <?php
    /**
    *
    * @package admag
    */

    get_header(); ?>

    <?php
    // Template layout is sticky sidebar
    if( dt_source::is_fixed_layout() ):
    ?>

    <div class=”fixed-main”>
    <div class=”fixed-main-wrapper main-wrapper”>

    <?php dt_print_ads(‘content-top’); ?>

    <div class=”main-content mag-content clearfix”>

    <div class=”row blog-content”>
    <div class=”col-md-12 main-wp”>
    <?php if ( have_posts() ) :
    get_template_part(‘template-parts/content’, ‘layout’);
    else :
    get_template_part( ‘template-parts/content’, ‘none’ );
    endif;
    ?>
    </div>
    </div>

    </div><!– .main-content –>

    <?php dt_print_ads(‘content-bottom’); ?>

    <?php get_template_part(‘template-parts/footer’, ‘fixed’); ?>
    </div>
    </div><!– .fixed-main –>
    <?php
    get_sidebar(“sticky”);
    ?>
    <?php
    // Else if simple layout
    else:
    ?>
    <!– Begin Main Wrapper –>
    <div class=”container main-wrapper”>

    <?php dt_print_ads(‘content-top’); ?>

    <div class=”main-content mag-content clearfix”>

    <?php
    $class = “col-md-8″;
    $left_sidebar = false;
    $right_sidebar = false;

    switch ( dt_source::get_layout_id() ) {
    // full width
    case ‘1’:
    $class=”col-md-12″;
    break;
    // left sidebar
    case ‘2’:
    $left_sidebar = true;
    break;
    // right sidebar
    default:
    $right_sidebar = true;
    break;
    }
    ?>

    <div class=”row inf-wrapper”>

    <?php if( $left_sidebar ): ?>
    <div class=”col-md-4 <?php echo ( dt_get_option(‘dt-sticky-sidebar’) ) ? ‘dt_sidebar’ : ”; ?>”>
    <?php get_sidebar(); ?>
    </div>
    <?php endif; ?>

    <div class=”<?php echo esc_attr( $class ); ?> main-wp <?php echo ( dt_get_option(‘dt-sticky-sidebar’) ) ? ‘dt_content’ : ”; ?>”>
    <?php if ( have_posts() ) :

    get_template_part(‘template-parts/content’, ‘layout’);

    else :
    get_template_part( ‘template-parts/content’, ‘none’ );
    endif;
    ?>
    </div>

    <?php if( $right_sidebar ): ?>
    <div class=”col-md-4 <?php echo ( dt_get_option(‘dt-sticky-sidebar’) ) ? ‘dt_sidebar’ : ”; ?>”>
    <?php get_sidebar(); ?>
    </div>
    <?php endif; ?>

    </div>
    </div><!– .main-content –>

    <?php dt_print_ads(‘content-bottom’); ?>

    </div><!– .main-wrapper –>

    <?php get_template_part(“template-parts/footer”, ‘main’); ?>
    <?php
    endif
    ?>

    <?php get_footer(); ?>

    #13281 Reply

    Masonry Guy
    Keymaster

    Hi,

    Ya, you need to copy the archive.php and then rename it to category.php if you want to keep for categories only. But if you want to do it for all like tags, author then you can just change the archive.php code.

    Regarding the code changes, those things depends upon how the theme has coded. Things to remember is you need to remove the wordpress loop code and use our plugin generic shortcode.

    So here, you need to change this lines to our shortcode.

    <?php if ( have_posts() ) :
    get_template_part(‘template-parts/content’, ‘layout’);
    else :
    get_template_part( ‘template-parts/content’, ‘none’ );
    endif;
    ?>

    Hope this helps.

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Category.php file can't be found in my theme files in order to generic shortcode
Your information: