-
AuthorPosts
-
December 12, 2020 at 12:49 pm #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 3 years, 11 months ago by Daniel.
December 12, 2020 at 2:55 pm #1266780you can try it with filter on that.
Put this to your child-theme functions.php
context blog goes with the context : indexadd_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);
December 12, 2020 at 3:17 pm #1266782if 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 */
December 13, 2020 at 2:44 pm #1266893December 14, 2020 at 10:28 am #1267057Hi @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,
DanielDecember 14, 2020 at 11:07 am #1267068But 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_argsNow 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.December 14, 2020 at 11:29 am #1267073by 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.December 14, 2020 at 12:38 pm #1267103Thanks @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.
-
AuthorPosts
- You must be logged in to reply to this topic.