Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

WordPress Meta_Query and Tax_Query

Featured Replies

OK, I might not be of much help here, but why are you getting the metaboxes value with filter input?

$hair_id = filter_input ( INPUT_POST, 'hair_id', FILTER_SANITIZE_STRING);

I would do it the WP way:

$hair_id = get_post_meta( get_the_ID(), 'hair_id', true );

Also I think a WP query would be better than get posts:

http://codex.wordpress.org/Class_Reference/WP_Query

 

Actually I don't know what's your scenario, so I might be wrong, but hope that helps a bit :)

OK, I might not be of much help here, but why are you getting the metaboxes value with filter input?

$hair_id = filter_input ( INPUT_POST, 'hair_id', FILTER_SANITIZE_STRING);

I would do it the WP way:

$hair_id = get_post_meta( get_the_ID(), 'hair_id', true );

Also I think a WP query would be better than get posts:

http://codex.wordpress.org/Class_Reference/WP_Query

 

Actually I don't know what's your scenario, so I might be wrong, but hope that helps a bit :)

idk what get_post_meta is for in wordpress since I don't do wordpress development that often but if he was getting data from a form field and also wanted to sanitize that data at the same time he would be on the right track by using filter_input however I will say if he is pulling in an integer from a form field which seems like he is he should be using FILTER_SANITIZE_NUMBER_INT instead of FILTER_SANITIZE_STRING

Edited by webdesigner93

Metaboxes are custom fields at the admin panel, where users can enter any data. get_post_meta is a function defined in the core that retrieves the metabox value.

I would imagine it would include one or other sort of data sanitization, but I am actually not sure - might have to have a look at the core and see how it's actually made.

 

Just enquired as it looks interesting to me - haven't seen metaboxes' values retrieved this way before in WP - it might be some plugin that does it :)

Metaboxes are custom fields at the admin panel, where users can enter any data. get_post_meta is a function defined in the core that retrieves the metabox value.

I would imagine it would include one or other sort of data sanitization, but I am actually not sure - might have to have a look at the core and see how it's actually made.

 

Just enquired as it looks interesting to me - haven't seen metaboxes' values retrieved this way before in WP - it might be some plugin that does it :)

Mmm interesting all I really could comment on is how you would do it in PHP outside of wordpress :) so your advice to the OP may of been right after all :)

Mmm interesting all I really could comment on is how you would do it in PHP outside of wordpress :) so your advice to the OP may of been right after all :)

 

Well, hopefully a WP guru will shed some light on the matter :)

  • Author

Hi guys, sorry I should of replied earlier.

So yes I am getting the fields from the front end and passing them into an ajax function. One of the fields is a true Id and the others are slugs, which is why I am using FILTER_SANITIZE_STRING on most of them except one.

The users on the front end select different boxes which are assigned slugs and one is an id, which is passed to the ajax function, this function is then used to query posts and return some data. What is happening at the moment is, it's returning data but it's not returning data that has ALL of the criteria, it's returning data that has some of the criteria and to be honest it's a bit random, but the same random each time... if that makes sense.

  • Author

I've asked everywhere I know and no one can help me with this, I am just wondering if it's a limitation with WordPress Meta Queries + Tax Queries.

  • Author

In case anyone was interested, I could not get this to work at all. So I ended up falling back to a MySQL query.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.