• hi, i have been tried to get the multicolumn with this code

    ?<?php
    
    add_filter('post_class', 'postclass_postspage_columns_correction');
    function postclass_postspage_columns_correction( $classes ) {
      global $wp_query;
      if ( is_home() || is_category() ) $classes[] = 'post-column-'.(($wp_query->current_post%2)?'right':'left');
    return $classes;
    }
    
    function individual_category_postsperpage( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_category() ) {
            $query->set( 'posts_per_page', 2 );
            return;
        }
    }
    add_action( 'pre_get_posts', 'individual_category_postsperpage', 1 );

    in the default theme
    i am trying to apply it to a another theme, and seems to do not work
    why?
    this is the site

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter stefanocps

    (@stefanocps)

    i forgot to write that it works with default them(with the code in css)

    Thread Starter stefanocps

    (@stefanocps)

    is it normal that it might work with a theme and not with another?seems more css problem anyway, as there is one column, and the second empty

    that theme ( https://www.ads-software.com/extend/themes/raindrops ) is using a html list for the output of the posts; with consecutive numbered css classes .loop-1, .loop-2, .loop-3 etc and only uses the post_class() for the article container within the li elements; therefore the css does not work.

    I don’t see any easy workaround;
    you will probably need to locate the loop for the posts and add some coding to the li tags to get the ‘two-column’ effect.

    try posting in the theme’s support section https://www.ads-software.com/support/theme/raindrops

    Thread Starter stefanocps

    (@stefanocps)

    or,as the main reason fot which i choose that templete is because of the 2 side bar
    might be easier to build 2 sidebar on a tewntywelve theme?

    build 2 sidebar on a tewntywelve theme?

    have a look at https://zeaks.org/tutorials/twenty-twelve-theme-three-column-layout/

    Thread Starter stefanocps

    (@stefanocps)

    i have inserted all that code, but i can only see one sidebar..it s enough code, so for now i have just copied and pasted

    Thread Starter stefanocps

    (@stefanocps)

    acutally what happen now is that i have no control on widget
    as i place theminto a widget area, the widget stop swhowing options.i just see the name of th ewidget but can’t open it anymore to change

    Thread Starter stefanocps

    (@stefanocps)

    no ok..it’s only strange behaviour.nee to click on save before can access to options.but still can’t see right sidebar

    Thread Starter stefanocps

    (@stefanocps)

    this is my functions.php in child
    when open it in editor(Microsoft expression web), it higlight the closing tag at the end, like if there is an error
    i can’t see an error though

    <?php
    
    add_filter('post_class', 'postclass_postspage_columns_correction');
    function postclass_postspage_columns_correction( $classes ) {
      global $wp_query;
      if ( is_home() || is_category() ) $classes[] = 'post-column-'.(($wp_query->current_post%2)?'right':'left');
    return $classes;
    }
    
    function individual_category_postsperpage( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_category() ) {
            $query->set( 'posts_per_page', 2 );
            return;
        }
    }
    add_action( 'pre_get_posts', 'individual_category_postsperpage', 1 );
    
      // Register extra sidebar
    function mytheme_widgets_init() {
        register_sidebar( array(
            'name' => __( 'Extra Sidebar', 'tto' ),
            'id' => 'sidebar-4',
            'description' => __( 'The Left Sidebar. Displayed on all but full width and homepage template.', 'mytheme' ),
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget' => "</aside>",
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ) );
    }
    add_action( 'widgets_init', 'mytheme_widgets_init' );
    
    <?php if ( is_active_sidebar( 'sidebar-4' ) ) : ?>
        <div id="extra-sidebar" class="widget-area" role="complementary">
            <?php dynamic_sidebar( 'sidebar-4' ); ?>
        </div><!-- .extra-sidebar .widget-area -->
    <?php endif; // end extra sidebar widget area ?>
    
    // Override content width (for photo and video embeds)
    $content_width = 500;
    
    // Display 1000px width content if full width page template
    function mytheme_content_width() {
        if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() ) {
            global $content_width;
            $content_width = 1000;
        }
    }
    add_action( 'template_redirect', 'mytheme_content_width', 11 );
    
    // Change default thumbnail size
    function mytheme_twentytwelve_setup() {
        set_post_thumbnail_size( 500, 9999 ); // (default featured images)Unlimited height, soft crop
    }
    add_action( 'after_setup_theme', 'mytheme_twentytwelve_setup', 11 );
    
    // Add child theme body class
    function mytheme_body_class( $classes ) {
    
         if( ! is_page_template() )
              $classes[] = 'custom-layout';
    
        return $classes;
    }
    add_filter( 'body_class', 'mytheme_body_class' );
    ?>

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘multi column in home and category’ is closed to new replies.