Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #415393

    Hey guys!
    First of all: thanks for your great theme and the last update a few days before – it’s just awesome!

    The masonry module on my site displays a single post category.
    My question: is it possible to add a filter hook, so the masonry module would display the single post category PLUS a product category?

    Thanks for your help!

    #415842

    Hey jolak!

    Unfortunately I don’t think there is an easy way to go about that. It would require a huge amount of custom work and you would need to hire a freelancer for it. You can find custom work on werkpress.com and https://studio.envato.com

    Feel free to make a feature request for Kriesi here: kriesi.at/support/enfold-feature-requests/

    Regards,
    Andy

    #424677

    Hey!
    Thanks for your answer.

    I worked on this and now i have a different solution:
    i created a custom field (with ACF) “product_url” and edited the masonry_entries.php like this
    instead of line 734:
    $this->loop[$key]['url'] = get_permalink($id);

    i have:

    if(get_field('product_url',$id)){
    $this->loop[$key]['url'] = get_field('product_url',$id);
    } else {
    $this->loop[$key]['url']= get_permalink($id);
    };

    This works pretty well.
    Now my question is: how can i hook this snippet into my childtheme?
    (i know i can’t just overwrite masonry_entries.php because it only works with template files – so there has to be some kind of hook… but i can’t get it!)

    Thanks for your help!!

    #424800

    Nobody who is familiar with enfold hooks?!

    #425255

    Hi!

    Not sure if this is going to work with the plugin but you can try to add this to the functions.php file:

    add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_loop_prepare_mod', 10, 2 );
    function avf_masonry_loop_prepare_mod( $key, $entries )
    {      
    	$id = $key['ID']; 
    	if($key['post_type'] == 'post') {
    		foreach ( $key as $post => $value ) {	
    			$field = get_field('product_url',$id); 
    			if($post == 'html_tags' && $field) { 
    				$value[0] = 'a href="' . $field .'"';
    			}	
    			$key[$post] = $value;
    		}
    	}
        return $key;
    }
    

    Best regards,
    Ismael

    #425267

    Hi Ismael,
    Yes, it works – thank you so much!!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add filter to masonry module – show post category and product category’ is closed to new replies.