Simple Frontend Post Filtering in WordPress | Custom Taxonomy Filter

Поделиться
HTML-код
  • Опубликовано: 26 окт 2024

Комментарии • 79

  • @birdbrainsolutions6112
    @birdbrainsolutions6112 4 года назад +14

    "Oh hi! I didn't see you there!" :)
    Can you make a tutorial for creating a search and dropdown filter for custom posts?

  • @iammukto
    @iammukto 4 года назад +3

    Please keep making video for mid level or advance wp dev.
    love this one 😍

  • @Rbog17
    @Rbog17 3 года назад +1

    I didn't know about those check functions for checked and selected. That's cool. Seems better than writing the shorthand conditional. Thanks.

    • @WPCasts
      @WPCasts  3 года назад

      They save a bit of thinking, which is nice. Glad you learned something new!

  • @schlotterich
    @schlotterich 4 года назад +2

    Thank you! Exactly what I was searching for. Much easier than my current solution

    • @WPCasts
      @WPCasts  4 года назад

      You’re very welcome!

  • @ericsackett
    @ericsackett 4 года назад +3

    Thank you for your straight forward explanations. Just supported you on Patreon. Can’t wait to see what your next video and courses are.

    • @WPCasts
      @WPCasts  4 года назад +1

      Thanks Eric, you are awesome!

  • @ashleyredman
    @ashleyredman 4 года назад +2

    Nice content, especially including nice usability items like keeping form state after submission. The only ‘problems’ I have with this sort of setup is that, frameworks like laravel have really easy ways using blade to do a similar thing, and when I use WP these days, I generally opt to use twig templates, completely separate out actual php in the ‘view’ so these WP helpers like ‘selected’ & ‘checked’ are not available. But that’s my choice to use that I suppose. Great content videos recently, thank you!

  • @philip9677
    @philip9677 4 года назад +3

    is there a way to do this dynamicall on select change in dropdown or radio without having to click apply button

  • @olaleyeabayomiimmanuel2527
    @olaleyeabayomiimmanuel2527 2 года назад

    This is really hepful, thank you!

  • @robeeeeen
    @robeeeeen 4 года назад

    Most easy way to do that really! Give us more videos please.

  • @agustindonna330
    @agustindonna330 9 месяцев назад

    Excellent post and a great solution, but I have a problem, I don't know if this solution works today, the part that is sorted alphabetically or by date, works, but not when I use the checkboxes.
    I have watched the video several times and I can't find my error, but I have noticed that it doesn't refer to how to filter by the "checkboxes" in the js . What could be my error (I know this is a very broad question)?
    Thanks

  • @J90JAM
    @J90JAM 2 года назад

    Nice tutorial dude 👌

  • @lanz7609
    @lanz7609 3 года назад +1

    Hi this is really helpful. Thank you so much! I was able to implement it immediately. But how do you filter using AJAX?

  • @ashleycam3ron
    @ashleycam3ron 4 года назад +1

    Excellent content on your channel! Thank you!

  • @aleezameansjoy
    @aleezameansjoy 2 года назад

    Awesome, got yourself a sub

  • @deepakkalra8132
    @deepakkalra8132 4 года назад +1

    Would be interesting to see how one could use React for the same use case, using of course the headless Wordpress setup... in which the posts (and thumbnails) come from Wordpress using something like GraphQL and our react app filters based on the selection in near real-time (without having to click submit)

  • @REgamesplayer
    @REgamesplayer 2 месяца назад

    How did you went into programming interface? It doesn't exist on my end. All I have is blocs for code and short code who doesn't work.

  • @drieq
    @drieq 4 месяца назад

    Hi! I'm encountering two issues here, one being the fact that my date sorting was already happening Newest to Oldest and got switched back to Oldest to Newest by the JavaScript. The other being that once I load my page, the dropdown is showing a PHP error because I haven't applied any value for "orderby".
    Any idea why that might be happening?

  • @petruciucur
    @petruciucur Год назад

    What about Backend Post Filtering? For example to decrypt title and content after retrieve encrypted content from database.

  • @petrolking7824
    @petrolking7824 3 года назад +1

    Thanks a lot for the video.
    I would like to know which tools did you use to code and how did you connect it to the WordPress?

    • @mehdiasghari7633
      @mehdiasghari7633 2 года назад

      Did you find your answer? If yes plz tell me too

  • @gplgr1978
    @gplgr1978 2 года назад

    Thanks for your effort! The only downfall a 404 error when using standard wp pagination.

  • @philip9677
    @philip9677 4 года назад

    This is very nice, works for CPT as well and sub categories

  • @andreasmou6539
    @andreasmou6539 3 года назад

    Hi there , I want to impelement this one , but looking the current Parent Category and bring the child of it, My Code before and was working but without checkbox $terms = wp_get_post_terms( $post->ID, 'product_category');
    Any Idea how to make the same with your filter type solution ?

  • @Uncaught_in_promise
    @Uncaught_in_promise 3 года назад

    Please make a tutorial on AJAX filtering pots by categories on button click (not checkbox), like a regular portfolio projects filtering. Also ho to make a "Show all" button. Thanx

  • @G15-n3u
    @G15-n3u 4 года назад +3

    Thanks for the tutorial. Can you make a tutorial wordpress with vuejs and graphql? Thank you very much.

    • @WPCasts
      @WPCasts  4 года назад +1

      The next Headless WordPress video I do will be more Gatsby centric. After that, I'll do one for Vue :)

    • @G15-n3u
      @G15-n3u 4 года назад

      @@WPCasts Thank you so much. Hope to be a good tutorial for beginners. Because there are a few tutorials like this. I'm following you!

  • @outpost31737
    @outpost31737 2 года назад

    Can this be used to filter by category? Having real problems coding up a button which allows users to sort posts by category.

  • @amb_channel
    @amb_channel 3 года назад

    Hi man thanks for the video, I just changed all "home_type" to "post_tag" that refer to tag parameter but the checkbox didn't work, i don't know why? could you help me please!

  • @ВасильВласюк-ь8т
    @ВасильВласюк-ь8т 18 дней назад

    What's name of theme you use for VS? Thanks

  • @epinefrin1000
    @epinefrin1000 2 года назад

    I made a custom taxonomy for the post type and added this filter. it works fine. but there is something i want to do.
    For example, the woocommerce attributes filter shows the filters related to the products in your category.
    I'm trying to do this in my category.php page. Now, when a category is entered, all filters are listed. is there a way to list only the filters included in that category's posts?

  • @adrkolev8037
    @adrkolev8037 4 года назад +1

    When your course comes?

  • @webniama6271
    @webniama6271 Год назад

    Nice content

  • @ShannonWhitty
    @ShannonWhitty 2 года назад

    Help? I followed this code and implemented. I am seeing my terms as options. I can select the options and when the page reloads, the options are remembered using checked() however... the posts aren't filtering - I am still seeing everything...

    • @theJett
      @theJett Год назад +1

      you made it further than me. I see my terms as options, can select the options but nothing happens when i click apply/submit. I'm not seeing any of my posts. Is the code in this index.php supposed to generate the posts somehow or is there other code outputting the cards (image, title, type)?

  • @janejames8955
    @janejames8955 3 года назад

    If you’re not on flywheel and doing this on a live site which page template is this going to show on?

  • @viktorkasap
    @viktorkasap 4 года назад +1

    Классный урок по фильтрации. Спасибо!

    • @WPCasts
      @WPCasts  4 года назад

      You're Welcome!

  • @schlotterich
    @schlotterich 4 года назад +1

    I am having trouble to load the taxonomies on my custom post type. When I try
    get_terms([
    'taxonomy' => 'events',
    'hide_empty' => false
    ]);
    I always get the error "Invalid taxonomy" in the var_dump. Can you maybe post a screenshot of your categories? where did you set the taxonomy "home_type"?
    Thank you very much

    • @WPCasts
      @WPCasts  4 года назад +1

      `events` sounds like a custom post type. In my video, `home_type` is a custom taxonomy that is registered with: codex.wordpress.org/Function_Reference/register_taxonomy

    • @schlotterich
      @schlotterich 4 года назад

      @@WPCasts Thank you so much for your answer. I solved the problem by creating a custom taxonomy. Unfortunately now I run into a new problem. The URL for example '?event-type=concerts' doesn't show any filtered results, but still the full range of events. Do I have to activate any settings in the taxonomy registration for that?

    • @schlotterich
      @schlotterich 4 года назад

      Ah I found out what the problem is. I am using a custom query to show the results. I need to find a way to apply the URL filter to the custom query

    • @schlotterich
      @schlotterich 4 года назад +3

      Okay I solved the problem now. I had to add a tax_query to my custom query and set the term to the submitted data

    • @dannes.6525
      @dannes.6525 4 года назад

      @@schlotterich This is exactly what I am needing to do. Are you able to share your solution with me if possible?

  • @bilalmalkoc
    @bilalmalkoc 3 года назад

    Hello. Mostly, i use tax_query or meta_query for filtering the posts. But this methods are using to much cpu. Can you advice more useful way?

  • @hikmatullah2131
    @hikmatullah2131 3 года назад

    Hi, Is this possible to private and restrict term of each individual user from other user in wordpress? so they can not edit , del, etc of other user terms in wordress.
    Thanks!

  • @lancerzalzos9517
    @lancerzalzos9517 4 года назад

    Hi, Thank you for your tutorial. I would like to ask if it is possible that when you login as user the articles and post are filter automatically and you can only view the articles or post that allow by administrator? Is that possible? Hope to hear from you soon. Thanks

  • @tadeuszrzewuski4913
    @tadeuszrzewuski4913 4 года назад

    Helped me a lot!
    Is there any way to make a taxonomy that automatically refers to the years posts are published and a starting checkbox that takes into account all taxonomies?
    i.e.
    All Years / 2020 / 2019 / 2018
    All Types / Condo / Single Family / Townhome

    • @WPCasts
      @WPCasts  4 года назад

      It would have to be a custom taxonomy, yes. I would just pre-pend the array with "All X" and when that is selected, you remove it from the query, which will do the same thing.

  • @Tony.Nguyen137
    @Tony.Nguyen137 5 месяцев назад

    How can I archieve this filter without clicking on apply button, this technique is used on e commerce website

  • @adevplayer4228
    @adevplayer4228 2 года назад

    Hi,
    How was the custom tax created? what if there is acf?

  • @TheProDat
    @TheProDat 2 года назад

    How can I do that on normal wordpress page instead of index?

  • @eotikurac
    @eotikurac 4 года назад

    i've been looking for a solution to filter posts by category for the last few days and nothing seems to work.

  • @doogie1385
    @doogie1385 2 года назад

    How to add active filter count and display it with close button?

  • @baykor7255
    @baykor7255 4 года назад +1

    Hello, are these posts Custom Post Types or default post types of WP?

    • @WPCasts
      @WPCasts  4 года назад +1

      These are custom post types, but you can easily do the same thing with regular posts

    • @baykor7255
      @baykor7255 4 года назад

      @@WPCasts Thanks. Expressly i would like to do the thing with custom posts. Firstly i have created php files for each category and then link them by in a static way. Now its clear that its easy to do it by GET attribute. Thanks a lot

    • @theJett
      @theJett Год назад

      @@WPCasts like everyone else, thanks for the walk-thru on this topic! I'm trying to work out how to do the same thing with the default (regular, out of the box) posts. I'm able to create the form with checkboxes but how to output the actual content after clicking apply? It looks like at the start of the video (time stamp around 1:28), that you have your floor plan output code there. thanks again!! cheers

  • @eotikurac
    @eotikurac 4 года назад

    this isn't working in my case. i get a bunch of errors related to wpml but even when i disable this plugin i never get any posts to list out.

    • @WPCasts
      @WPCasts  4 года назад

      Try disabling the rest of your plugins and try again

  • @TheMarouuu
    @TheMarouuu 4 года назад

    You are a mind reader :D

  • @ЕвгенийМедведев-г8и

    Hello, where did I go wrong. With checkbox name="objectcat[]" All posts are shown. If you remove the brackets and do name="objectcat". This will show the posts of the last selected checkbox.

  • @lhiggo
    @lhiggo 4 года назад

    Hey Mate, do you need to sanitize $_GET keys?

  • @andcaru
    @andcaru 4 года назад

    Thanks for sharing

  • @saravanankanagaraj2990
    @saravanankanagaraj2990 4 года назад

    How to apply this filter for search result page in elementor with Last modified & Recently added filter options.

  • @KailashKumar-cy1yz
    @KailashKumar-cy1yz 4 года назад

    Hii For the AJAX filter for blog post and custom post time check this plugin: wordpress.org/plugins/category-ajax-filter/

  • @RashtradeepTripathi
    @RashtradeepTripathi 4 года назад

    Sir, I need your help in troubleshooting my website.

  • @stasonnl777
    @stasonnl777 4 года назад

    Can you please explain how to make the same for custom post type?

    • @PaweBystrzan
      @PaweBystrzan Год назад

      Then you need to have: hidden field with id="" and name="post_type" or if you want to choice beetwen them - copy solution from select or checkboxes (just remember the 'post_type' parametr. The post type key (slug) you need to set as a value you'll find in url while on WP admin post list screen).

  • @hefni5237
    @hefni5237 4 года назад +1

    What's the name of your vscode theme ?

    • @WPCasts
      @WPCasts  4 года назад +1

      marketplace.visualstudio.com/items?itemName=taniarascia.new-moon-vscode

    • @hefni5237
      @hefni5237 4 года назад

      @@WPCasts thank you 😊

    • @theJett
      @theJett Год назад

      got it too

  • @KunalGautam
    @KunalGautam 4 года назад

    It is trending today on r/Wordpress