Did you add a Custom Taxonomy for your different types of seeds? If you did, you can use Beautiful Taxonomy Filters or Search & Filter to create filters of your content based on Taxonomy (Seed Type)
Both require an Archive page to be set for your post type, which is looks like you’ve created at vademecum; this is a list of your posts ‘seeds’, using the default archive.php from WordPress or a custom archive-seeds.php
Thread Starter
comodo
(@comodo)
Hi again, no. I didn´t add a taxonomy field. Anyway i could “solve” the problem using only jquery and plugin Mixitup. Adding class to every element and filter with this plugin, as you can see, http://yesweskunk.com/es/vademecum/
Thank you very much. I will take care adding taxonomy field next time 😀
That’s actually a really smart solution, especially since you have access to the ‘categorization’ fields and can output them as class attributes. Elegant and smart solution for providing ajax filtering on the front-end!
Gonna add that to our list 😉
I am also interested in this kind of filtering. Could you explain your solution more in Detail? What plugin do you exactly mean with Mixitup? Is it possible to use this with taxonomies
Or is there a better way for live/ajax filtering by taxonomy? Beautiful Taxonomy Filters and Search & Filter always redirect to another page. Also I dont need a submit button or dropdowns. The user should just be able to click on the name of the taxonmy.
@cgdannie FacetWP does the filtering you’re talking about on the same page. It is a premium plugin, though.
https://facetwp.com/
Thread Starter
comodo
(@comodo)
@cgdannie Mixitup is a javascript plugin or a small javascript library for creatin filters. You have to include this plugin in your theme. After that, you will to create a filter system, each item of this filter will have a class name that must be equals to the class of the elements that you want to show or hide.
It is a very easy plugin with a good documentation. I am not very good in english and i am not a good programmer, but after 30 minutes reading the documentation i got a “good” solution.
https://www.kunkalabs.com/tutorials/
Thank you both very much. I got it to work by adding the taxonomy in the pods template as a class. Then I can insert a pods list with the pods list widget.
For the filter buttons I then added the following code with the PHP Code Widget on the page (https://de.wordpress.org/plugins/php-code-widget/).
Is there something I can optimize in this workflow?
<?php
define('TAXONOMY', 'my-taxonomy');
define('CONTAINER_CLASS', 'my-container');
?>
<div class="controls">
<?php
$taxonomies = get_terms( array(
'taxonomy' => TAXONOMY,
'hide_empty' => false,
) );
?>
<button type="button" data-filter="all">All</button>
<?php foreach($taxonomies as $taxonomy): ?>
<button type="button" data-filter=".<?= $taxonomy->slug ?>"><?= $taxonomy->name ?></button>
<?php endforeach; ?>
</div>
<script>
document.onreadystatechange = function () {
if (document.readyState == "interactive") {
var container = document.querySelector(".<?= CONTAINER_CLASS ?>");
var mixer = mixitup(container);
}
}
</script>
-
This reply was modified 8 years, 7 months ago by
cgdannie.