February 19, 201511 yr I am expecting too much from WordPress. Should this meta_query and tax_query combined work like I expect it to?http://pastebin.com/cC9q7BR7 Thanks for any help.
February 19, 201511 yr 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
February 19, 201511 yr 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 February 19, 201511 yr by webdesigner93
February 19, 201511 yr 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
February 19, 201511 yr 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
February 19, 201511 yr 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
February 19, 201511 yr 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.
February 20, 201511 yr 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.
February 20, 201511 yr 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