-
AuthorPosts
-
January 4, 2021 at 5:01 pm #1270201
Hello there,
I’m looking to have my portfolio grid open up on a specific category (Radiographic Systems) so it only shows that category instead of opening up on all.
I tried to input the coding into the .PHP but it didn’t seem to make a change.
I have posted the page I’m talking about in private content.
January 7, 2021 at 7:48 am #1270798Hey RMcKee,
Thank you for the inquiry.
The following script should activate the Radiographic Systems category sort item on page load. Please add the snippet in the functions.php file
// activate a specific category sort item function ava_activate_sort_button() { if ( wp_script_is( 'avia-default', 'registered' ) ) { wp_add_inline_script( 'avia-default', '(function($) { $(document).ready( function() { $(".radiographic-systems_sort_button").trigger("click"); }); })(jQuery); '); } } add_action( 'wp_enqueue_scripts', 'ava_activate_sort_button', 9999);
Best regards,
IsmaelJanuary 7, 2021 at 4:25 pm #1270897Hello there,
I added this into the functions.php but it did not activate Radiographic Systems on page load.I don’t believe there were any changes on the page.
Thank you in advance,
RobJanuary 11, 2021 at 3:34 am #1271440Hi,
Thank you for the info.
We noticed that there is a minor syntax error in the above code, so we removed it. Sorry about that. Please try the snippet again or post the login details in the private field so that we could test the script properly.
Best regards,
IsmaelFebruary 8, 2021 at 6:27 pm #1278756Hi,
I have a similar request but have two different portfolio grids and like to activate in each portfolio grid a different category?
I tried to solve this by your advices to have the first category activated but with Safari and Firefox the activated category is not active if you clicked to an other page and returned.Best regards,
VeraFebruary 9, 2021 at 12:31 pm #1279030Hi,
@vera: You may need to apply a custom css class name or ID to each Portfolio Grid element and use it to toggle the appropriate sorting button of each element accordingly. The class and ID field is in the Advanced > Developer Settings toggle of the Portfolio Grid element.
// https://kriesi.at/documentation/enfold/add-custom-css/#enable-custom-css-class-name-support
If you use portfolio-1 and portfolio-2 in the class name field of the two portfolio grid elements respectively, the changes may look something like this.
$(".portfolio-1 .radiographic-systems_sort_button").trigger("click"); // activate radiographic-systems category for the portfolio grid 1 $(".portfolio-2 .other-systems_sort_button").trigger("click"); // activate other-systems category for the portfolio grid 2
Best regards,
IsmaelFebruary 9, 2021 at 3:00 pm #1279101Hi Ismael,
thank you for your reply. As you suggested I created two different CSS-classes (.portfolio-arch and .portfolio-aus) and added the script like this to the functions.php of my child theme. But it has no effect. Do I have to do something additional?
Best regards,
Vera//------------------------------ // activate a specific category sort item //------------------------------ function ava_activate_sort_button() { if ( wp_script_is( 'avia-default', 'registered' ) ) { wp_add_inline_script( 'avia-default', '(function($) { $(document).ready( function() { $(".portfolio-arch .praesentationsmodelle-modellbau-architektur_sort_button").trigger("click"); $(".portfolio-aus .auswahl-anschauungsmodelle_sort_button").trigger("click"); }); })(jQuery); '); } } add_action( 'wp_enqueue_scripts', 'ava_activate_sort_button', 9999);
February 10, 2021 at 1:10 pm #1279410Hi,
Thank you for the update.
That looks about right except for the converted quotation marks. You may need to correct it for the scripts to work properly.
Best regards,
IsmaelFebruary 12, 2021 at 5:25 pm #1280115Hi Isamel,
thanks for the correction of the quotes. Still it’s not working. Do you have any further suggestion? Perhaps this is already too advanced for me as a non-programmer? An alternative solution would be what the “documentation > portfolio grid > Load a default portfolio category” recommends to show a specific category. This works fine but is not active anymore when you “reenter“ a page after skipping through the navigation under Firefox and Safari. Only under Chrome it’s always active. Thanks again for your help.Best regards,
VeraFebruary 15, 2021 at 2:42 pm #1280549Hi,
Thank you for following up.
Would you mind providing access to the WP dashboard and/or the file server? We will try to implement the changes above and add the script in the functions.php file. Please post the login info in the private field.
Best regards,
IsmaelFebruary 15, 2021 at 5:10 pm #1280587Hi Ismael,
thanks for your reply. Here are the requested infos.
Best regards,
VeraFebruary 16, 2021 at 2:06 pm #1281333Hi,
Thank you for the info.
We adjusted the script in the functions.php file a bit so that it actually looks for the sort container and the appropriate category button. It seems to be working properly now. (see private field)
This is the updated script.
// activate a specific category sort item function ava_activate_sort_button() { if ( wp_script_is( 'avia-default', 'registered' ) ) { wp_add_inline_script( 'avia-default', '(function($) { $(document).ready(function() { $(".portfolio-arch").prev().find(".praesentationsmodelle-modellbau-architektur_sort_button").trigger("click"); $(".portfolio-aus").prev().find(".auswahl-anschauungsmodelle_sort_button").trigger("click"); }); })(jQuery); '); } } add_action( 'wp_enqueue_scripts', 'ava_activate_sort_button', 9999);
Best regards,
IsmaelFebruary 16, 2021 at 2:36 pm #1281347Hi Ismael,
great! Thank you very much for the adjustments. Now it works perfectly.
Best regards,
VeraFebruary 18, 2021 at 3:59 am #1281925 -
AuthorPosts
- You must be logged in to reply to this topic.