• Resolved ericvandenberge

    (@ericvandenberge)


    I want to use a filter method on a custom post type registered with the custom post type ui plugin. I have a problem with doing that and more people have this problem. They say it has to do with the registering of the custom post type and the taxonomies after the init. Do you know if that’s a problem within the plugin?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Nothing that our plugin is doing should be preventing tax_query arguments from working with WP_Query.

    Something to keep in mind is that with tax_query, you’re still querying for posts of some sort, but limiting the query to just results that match your tax query in some way.

    If you provide a bit more about what results you’re looking for and what their related taxonomy setup is like, I can try to offer some more detailed suggestions.

    Thread Starter ericvandenberge

    (@ericvandenberge)

    Hi Michael,

    I am aware of that the selection is smaller if i filter it more but that’s not the problem. The solution they gave was this answer on stackoverflow. Some other people said it worked for them but i cannot change this because i use the plugin. the solution they gave was this:

    First of all, you run register_post_type on init and register_taxonomy on after_setup_theme which is called after init. This means your custom taxonomy will not be available when registering the post type. I would suggest you remove the taxonomies keyword from the register_post_type arguments array, and just register the taxonomy manually afterwards. In your example code it looks like you are creating the post type-taxonomy link twice.

    It could be another problem, but i wanted to check if its maybe in the plugin.
    here is the reference of my problem.

    https://stackoverflow.com/questions/14709719/tax-query-not-working-with-wp-query

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Still not an issue that I can think of that’d stem from our plugin.

    Instead of trying to got based on reported issues from others from notably old StackOverflow threads, let’s start from the proverbial top for your issue specifically.

    What post type(s) do you have registered
    What taxonomies are you associating them with
    What posts and terms do you have published that you feel should be showing up, but are not
    What is the code you’re using to try and run a tax_query with them
    What are the results you’re seeing after you have the query made

    Let’s work this out 😀

    Thread Starter ericvandenberge

    (@ericvandenberge)

    Awesome that you want to work the problem out :).

    i’ve written a stackoverflow post a few hours ago with the questions you asked in your comment. I hope the question is clear enough so you can understand :).

    here is the link:
    https://stackoverflow.com/questions/59136438/tax-qeury-not-working-in-wordpress-how-to-solve

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Will try to review in greater detail soon.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not seeing anything inherently wrong with the code used, so I’m doubtful that’s the issue really.

    The question then ends up falling back to the content and what you may or may not have published.

    Do you have, for sure, any “vacature” posts PUBLISHED that have the “noord-brabant” term from the “provincie” taxonomy. Is the term ID for “noord-brabant” the number 3?

    When you visit the term list for this taxonomy, and you look at “noord-brabant”‘s line item, on the far right, does it list any number above 0 ?

    Just in case it’s affecting things, remove the 'paged' parameter.

    Thread Starter ericvandenberge

    (@ericvandenberge)

    I think i know wat the problem is i am facing.
    I didn’t registered the taxonomy on the post.
    I use the ‘advanced custom fields’ plugin to fill in my ‘vacature’ post in the backend.
    I registered to ‘advanced custom fields’ that i linked my post to ‘noord-brabant’ but the post itself doesn’t have that info.
    Do you know how to solve it?

    So you’re right. i’ve not registed ‘noord-brabant’ to any post. i registered it to the ‘advanced custom plugin’ field.

    Thread Starter ericvandenberge

    (@ericvandenberge)

    I made an image to make it understandable. on the right side of the screen on the red cross i need to link the ‘provincie’ to the post for tax_query to work. but i’m using the ‘advanced custom fields’ plugin where i link (on the left at the green check mark) to the post. But i don’t want to show the widgets on the right side. i wan’t to use the ‘advanced custom fields’ plugin to register.

    Here is the image to make it more clear
    https://we.tl/t-AZSFR3YJhh

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    With that new information, it sounds like you’re not assigning terms at all, you just have an ACF field that has these MBO, HAVO, etc value pairs being saved as ACF post meta, and not terms at all.

    I would register the taxonomy to be associated with this intended post type, and then regarding the metabox part where you want ACF to handle, set the meta_box_cb field to “false” since you’re still using Classic editor. You may need to re-review the ACF settings for this to see if you now have a “taxonomy” based field type to use instead, that way the ACF would save as term data.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘wordpress Tax_query not working’ is closed to new replies.