Hi,
I would like to ask if its possible to change the default ordering when adding categories to be loaded with ajax.
As far as I know, no matter the order we add the categories, they will display with alphabetical order in the ajax dropdown.
So is there a way to bypass that, and display in ajax dropdown the categories based on the category ID sequence we have inserted them?
I managed to make a fix, but I don’t know if it is recommended
at Newspaper->includes->wp_booster->td_block.php
at line 74
I managed to fix this by replacing this code
$td_categories = get_categories(array(
'include' => $td_ajax_filter_ids,
'exclude' => '1',
'number' => 100, //limit the number of categories shown in the drop down
));
foreach ($td_categories as $td_category) {
$td_pull_down_items []= array (
'name' => $td_category->name,
'id' => $td_category->cat_ID,
);
}
with this
$token = strtok($td_ajax_filter_ids, ", ");
while ($token !== false){
$td_categories = get_categories(array(
'include' => $token,
'exclude' => '1',
'number' => 100, //limit the number of categories shown in the drop down
));
foreach ($td_categories as $td_category) {
$td_pull_down_items []= array (
'name' => $td_category->name,
'id' => $td_category->cat_ID,
);
}
$token = strtok(", ");
}
As I see there are certain sorting options for sorting categories based on wordpress get_categories function…
The only approach I managed to follow was tokenize each entry in the list and then, produce isolated result for each entry, thus produce result sorted by the order in which the IDs were typed.
I would like to know if there is some better approach to this, without changing too much of the original template.
Yet it would also be more than welcome to get an official fix for that from the template itself, so we don’t have to update that code whenever new template version is up.
Thank you
Hi neakriti,
I have added this on our list and we will try to find a solution for this for future updates, so you will not have to alter the code. We have provided some solutions for this, like sort order by slug and control categories from category slug name – https://forum.tagdiv.com/topic/can-i-reorder-ajax-dropdown-on-my-own/#post-64762
Also I see that Category Order and Taxonomy Terms Order plugin helps many user to order categories, you can try it until we find a fix for it.
Thanks!
Thank you for your reply. I am in no need for yet another plugin. Since I managed to alter code myself, I can live with that until some future update encorporate this functionality.
However I would like if possible to know what php files can be overriden through the child theme and which cannot.
For example the Newspaper->includes->wp_booster->td_block.php does not affect anything if placed inside the child theme, unfortunatelly it has to be changed inside the main theme only.
So what folders/files can we change in child theme without fear of overwites on the main theme?
Thank you
Hi
You can check the file which have child theme support in our documentation: https://forum.tagdiv.com/the-child-theme-support-tutorial/
If you use child theme for files customizations it’s a good practice to check update_log.txt file for each update and see what files had been modified so if those specific files are used in the child theme you will have to check your customizations to not break the functionality of the theme.
Thanks!