[Support request] Switch off masonry on specific taxonomies

Home Forums Support [Support request] Switch off masonry on specific taxonomies

Home Forums Support Switch off masonry on specific taxonomies

Viewing 15 posts - 1 through 15 (of 33 total)
  • Author
    Posts
  • #646660
    Hans

    Hi everybody,

    on specific taxonomy archives I use alphabetical order. I acchieved it by this code:

    function member_abc( $query ) {
        if (($query->is_tax('ausschuss')) || ($query->is_tax('amtingemeinde')) ||($query->is_tax('ansprechpartnerin')) || ($query->is_tax('aufgabe')) || ($query->is_tax('funktionov')) || ($query->is_tax('mandat')) || ($query->is_tax('fraktionov'))) {
            $query->set( 'orderby', 'name' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'pre_get_posts', 'member_abc' );

    On exactly these archives I do not want to apply masonry as this destroys the abc-order from left to right. Which code will solve the problem?

    #646865
    Hans

    I tried this code:

    add_filter( 'generate_blog_masonry', 'tu_adjust_masonry' );
    function tu_adjust_masonry( $masonry ) {
        if ((is_tax('ausschuss')) || (is_tax('amtingemeinde')) ||(is_tax('ansprechpartnerin')) || (is_tax('aufgabe')) || (is_tax('funktionov')) || (is_tax('mandat')) || (is_tax('fraktionov'))) {
            return 'false';
        }
    
        return $masonry;
    }
    

    It did not work.

    #647025
    Leo
    Staff
    Customer Support

    Hi there,

    Can you try this:

    add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    function tu_portfolio_masonry( $masonry ) {
        if ( is_tax( 'tax1', 'tax2')  ) {
            return 'false';
        }
    
        return $masonry;
    }
    #647049
    Hans

    Hi Leo,

    it did not help!

    #647154
    Tom
    Lead Developer
    Lead Developer

    Are those the taxonomies, or the terms?: https://codex.wordpress.org/Function_Reference/is_tax

    Ideally, it would be like this:

    add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    function tu_portfolio_masonry( $masonry ) {
        $taxonomies = array(
            'some-taxonomy',
            'another-taxonomy',
            'one-more',
        );
    
        if ( is_tax( $taxonomies ) ) {
            return 'false';
        }
    
        return $masonry;
    }
    #647166
    Hans

    Hi Tom,

    this did not chnge the situation. The taxnomy is part of a cpt. Might this be the source of trouble? I use the follwoing content-template:

    <?php
    /**
     * @package GeneratePress
     */
    ?>
    
    <!-- Hans Keutgen Neue Datei für Theme - Mitglieder hehandeln -->
    
    <style>
    .post-image img {
    	display: center;
        margin-left: auto;
        margin-right: auto;	
    }
    </style>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_article_schema( 'CreativeWork' ); ?>>
    	<div class="inside-article">
    		<?php do_action( 'generate_before_content'); ?>
    		<header class="entry-header">
    			<?php do_action( 'generate_before_entry_title'); ?>
    			<?php if ( generate_show_title() ) : ?>
    				<?php the_title( '<h1 class="entry-title" itemprop="headline">', '</h1>' ); ?>
    			<?php endif; ?>
    			<?php do_action( 'generate_after_entry_title'); ?>
    		</header><!-- .entry-header -->
    		<?php do_action( 'generate_after_entry_header'); ?>
    		<div class="entry-content" itemprop="text">
    			<?php // the_content(); ?>
    			<?php
    			wp_link_pages( array(
    				'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
    				'after'  => '</div>',
    			) );
    			?>
    		</div><!-- .entry-content -->
    		
    		<?php do_action( 'generate_after_entry_content' ); ?>
    		<?php do_action( 'generate_after_content' ); ?>
    	</div><!-- .inside-article -->
    </article><!-- #post-## -->
    

    The code is in a child theme.

    #647441
    Tom
    Lead Developer
    Lead Developer

    Any chance you can link me to one of those taxonomy archives?

    #647567
    Hans

    I send the access data to your pre-sales support. The easiest way to see what happens: Look on menu bar “Ortsverein -> Who is who”. This is an example of taxonomy ‘fraktionov’ and CPT ‘mitglieder’.

    #648047
    Tom
    Lead Developer
    Lead Developer

    Just as a test, does this work?:

    add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    function tu_portfolio_masonry( $masonry ) {
        if ( is_archive() ) {
            return 'false';
        }
    
        return $masonry;
    }

    It will apply to all archives, so it’s not the solution, but I just want to know if it works or not.

    #648117
    Hans

    Hi Tom,

    unforturnately it changed nothing – even archives stay in masonry.

    #648234
    Tom
    Lead Developer
    Lead Developer

    That tells us something. Let’s go back to our original function, and change it to this:

    add_action( 'wp', function() {
        add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    } );
    
    function tu_portfolio_masonry( $masonry ) {
        $taxonomies = array(
            'some-taxonomy',
            'another-taxonomy',
            'one-more',
        );
    
        if ( is_tax( $taxonomies ) ) {
            return 'false';
        }
    
        return $masonry;
    }
    #648316
    Hans

    Hi Tom,

    things seem to become more complicated. Masonry is still there but additional problems have come up. Some taxonomies have no longer columns. I have to investigate this and will report tomorrow.

    #648578
    Tom
    Lead Developer
    Lead Developer

    Sounds good – let me know what you find out.

    #648811
    Hans

    Hi Tom,

    I did not find a reason why there are three columns or one column in the taxonomies view in your last proposal. Prior to your last proposed code there where always three columns – all of them had the mansonry view.

    When you enter the site – I send the access data to your pre-sales desk, you find the view as I designed it. Just go to “Examples” in the secondary menu under the primary one. There you find different views on taxonomies. When you enter Dashboard -> Snippets, the two deactivated snippets at the end of the list are your proposals. The penultimate snippet – your latest proposal – gives three/one column(s) back. The last one doesn’t change anything – your first proposal.

    I checked the taxonomy definitions – they are all exactly the same.

    My wish is still to have these taxonomies in non-masonry view to get an alphabetical order despite of the size of the featured Image and lenghth of title.

    #649510
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    So your “Who is Who” page is using this taxonomy: fraktionov

    That was missing from the function. I added it to the code snippet, and masonry was disabled. Columns were also disabled though – do you want those back?

Viewing 15 posts - 1 through 15 (of 33 total)
  • You must be logged in to reply to this topic.