Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1266761

    Hi,

    I have changed the amount of columns that are used in the grid layout for blog and category pages from 3 to 2 by copying index.php and archive.php to my child theme and then changing archive.php and index.php lines:

    'columns' => 2,
    

    This works, which is great, but isn’t there a more flexible solution? The more files I manually change, the higher the risk becomes that updates are causing issues. Is there a way to use my functions.php file for this?

    Hope you can help, thanks!
    Daniel

    • This topic was modified 4 years ago by Daniel.
    #1266780

    you can try it with filter on that.
    Put this to your child-theme functions.php
    context blog goes with the context : index

    add_filter('avf_post_slider_args', function($atts, $context){
      global $posts;
      if($context == 'index') {
        $atts['type']  = grid; 
        $atts['columns']  = 2;
      } 
      if($context == 'archive') {
        $atts['type']  = grid; 
        $atts['columns']  = 4;
      }
      if($context == 'tag') {
        $atts['type']  = grid; 
        $atts['columns']  = 5;
      }
      return $atts;
    }, 10, 2);

    shortversion if the column-count is the same:

    add_filter('avf_post_slider_args', function($atts, $context){
    	global $posts;
    	if($context == 'index' || $context == 'archive' || $context == 'tag') { $atts['columns']  = 2;}
    	return $atts;
    }, 10, 2);
    #1266782

    if you do not have child-theme you can manage it by functions.php of parent – but then again an update will overwrite all settings there.
    the right place to insert those snippets it at the bottom of funcitons.php
    just before :

    require_once( 'functions-enfold.php');
    

    there is a comment on that place :

    /*
     *  register custom functions that are not related to the framework but necessary for the theme to run
     */
    #1266893

    Hi,

    Thanks for helping out @guenni007, did those answers help you out @daniel?

    Best regards,
    Rikard

    #1267057

    Hi @Guenni007,

    this works like a charm, thanks so much. If I would want to learn to do this myself, where would be a good place to start, you think?

    Thanks again,
    Daniel

    #1267068

    But I think you are on a good way, if you already found the places in the source code where it has to be changed.
    f.e on index.php – some lines under your columns (count) you see that filter (line55) avf_post_slider_args

    Now this is not general knowledge like css or jQuery which serves as a basis for something like this.
    It is pure Enfold knowledge. Enfold has a lot of hooks and filters already built in.
    So I look at the list of hooks and filters and try to find out what they are for.
    btw.: the list is not complete – if you search the whole enfold folder for “do_action” you will find a lot of possibilities.

    By the way, it is very helpful to create a small file in which you write down such snippets with the purpose they have and possibly with a link to the post that refers to the application.

    2nd : the documentation is well done and is usually ignored as an aid.

    3rd : Read, read, learn.
    By not only following my questions here, but also reading through questions from other participants, I get a good coverage of problems that can arise using the Enfold theme. Every question that is asked here – could also be a question from my customers to me.
    If you look at my postings from the beginning here, you’ll see that I wasn’t exactly the expert either. The trick is to question the answers as to why the solutions offered work.

    #1267073

    by the way dear Mods – it would be nice to have an info on newly added filters how to use them with a little example.
    maybe on github – but better on the board itself or in documentation. Or as a link to a page from the changelog text where the added filters are listed.
    f.e.: avf_lightbox_show_alt_text etc.

    #1267103

    Thanks @Guenni007, for your time to help others and let them learn too. I really appreciate all your lengthy and in depth answers.

    I created a code wiki and added my first snippet.

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