Nyasha
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Fixing WordPress
In reply to: Portfolio FiltersHi @herussell33 https://www.ads-software.com/plugins/blog-filter/ may work for what you’re looking for. You can make them categories and sort that way.
In addition, This is not a plugin but some code that uses a similar function if you choose to go the code route (it should look something like this https://demos.understrap.com/portfolio-child-theme/ you may need to refresh the page) :
<?php /** * The main template file. * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is used to display a page when nothing more specific matches a query. * E.g., it puts together the home page when no home.php file exists. * Learn more: https://codex.www.ads-software.com/Template_Hierarchy */ // Exit if accessed directly. defined("ABSPATH") || exit(); get_header(); $container = get_theme_mod("your_theme_container_type"); ?> <div class="<?php echo esc_attr($container); ?>" id="content" tabindex="-1"> <div class="wrapper" id="index-wrapper"> <div class="row"> <!-- Do the left sidebar check and open the primary div --> <?php get_template_part("global-templates/left-sidebar-check"); ?> <main class="site-main row" id="main"> <?php if (have_posts()): ?> <?php $tax_terms = get_terms([ "taxonomy" => "category", "hide_empty" => false, "exclude" => get_cat_ID("uncategorized"), ]); if (is_array($tax_terms) || is_object($tax_terms)) { echo "<div class='container'><ul class='nav' id='filters'>"; } echo '<li id="filter--all" class="nav-link filter selected" data-filter="*"><a href="#" class="nav-item">' . esc_html("All", "your-theme-textdomain") . "</a></li>"; foreach ($tax_terms as $tax_term) { echo '<li class="nav-link filter" data-filter=".' . esc_attr($tax_term->slug) . '"><a href="#" class="nav-item">' . esc_html($tax_term->name) . "</a></li>"; } echo "</ul></div>"; ?> <div class="w-100 p-0 " id="portfolio-grid"> <?php while (have_posts()): the_post(); ?> <?php /** * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part("loop-templates/preview", get_post_format()); ?> <?php endwhile; ?> </div> <?php else: ?> <?php get_template_part("loop-templates/content", "none"); ?> <?php endif; ?> </main><!-- #main --> <!-- The pagination component --> <?php your_theme_pagination(); ?> <!-- Do the right sidebar check --> <?php get_template_part("global-templates/right-sidebar-check"); ?> </div><!-- .row --> </div><!-- #content --> </div><!-- #index-wrapper --> <?php get_footer();
You would need to :
- Replace
your_theme_container_type
with the appropriate container class or ID for your theme. - Replace
your-theme-textdomain
with the text domain used in your theme for translation purposes. - Replace `your_theme_pagination with your pagination function.
I hope either the plugin or code helps!
- Replace
Viewing 1 replies (of 1 total)