derschwede
Forum Replies Created
-
Forum: Hacks
In reply to: posts_where filter is ignoredHey Daniel,
wow thats quite some time gone 😀
Jepp i finaly made it – honestly i do not know for sure what projekt it was …
What i remember that it had nothing to do with the syntax – all of the above worked.It was more a “wrong” placement of the hook.
If i remember correct i tried to place the code in different files, starting with index.php
and worked my way down the includes – and it worked then.It was one of this ” why didnt i try the easiest thing at the beginning” moments.
Maybe this will help you . I can recheck if i find the code i worked on and then i will come back to you here.
BR
Forum: Hacks
In reply to: posts_where filter is ignoredjeep maybe , but all of them should be targeted by the last stand alone
“AND wp_posts.ID = 1”
so in fact not one single post , is valid if it is not ID: 1
the trigger isn’t used… thats my point, the syntax is correct,but it is just ignored
and i have no clue why…i am going to search deeper in the query.php , but i do not want to make changes here,
to keep the system up-dateable.thankx for your time bro – i appreciate that – but maybe somebody ready that who knows why the filter just does nothing 😀
Forum: Hacks
In reply to: posts_where filter is ignoredgood point, but nope…
i tried to make it more direct nowArray ( [where] => AND (((wp_posts.post_title LIKE '%sports%') OR (wp_posts.post_content LIKE '%sports%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND wp_posts.ID = 1 [groupby] => [join] => [orderby] => wp_posts.post_date DESC [distinct] => [fields] => wp_posts.* [limits] => LIMIT 0, 7 )still got the same search result, with all posts that contain “sports”
Forum: Hacks
In reply to: posts_where filter is ignoredprint_r($where); from post_where filter says
AND (((wp_posts.post_title LIKE '%sports%') OR (wp_posts.post_content LIKE '%sports%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND wp_posts.ID IS IN (1,2,3)but this is not surprising 😀
Forum: Hacks
In reply to: posts_where filter is ignoredsure. here you have the print_r ($input) from the post_clauses filter:
Array ( [where] => AND (((wp_posts.post_title LIKE '%sports%') OR (wp_posts.post_content LIKE '%sports%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND wp_posts.ID IS IN (1,2,3) [groupby] => [join] => [orderby] => wp_posts.post_date DESC [distinct] => [fields] => wp_posts.* [limits] => LIMIT 0, 7 )Forum: Hacks
In reply to: posts_where filter is ignoredHi Eric,
on your first post. No i think case sensitivity is not the problem. I found nothing in the query.php that looked like an “sql validator” and i can also write
” AND cgvjhkblöhlgkcjfcgkjhljö” and nothing happens.on your second post:
thanks for the posts_clauses filter , its good to have all parts in one filter, but same result here.it just doesn’t impact the search.
i have this code now:
function se_postStrip ($where) { global $wpdb; if ( is_search() && isset($_GET['s'])) { $where .= " AND ".$wpdb->posts.".ID IS IN (1,2,3) "; } return $where; } add_filter ('posts_where', 'se_postStrip'); function my_posts_request_filter( $input ) { global $wpdb; print_r( $input ); } add_filter( 'posts_clauses', 'my_posts_request_filter' );and in the print_r of the posts_clauses filter , i see that the additional where statement was added in the post_where filter, but i still get post ID 4747 in the search result,
and 4747 is NOT IN (1,2,3) 😀so no look until now
Forum: Hacks
In reply to: posts_where filter is ignoredHi Eric,
yes it does.
If i echo, or print_r $where i get the where statement matching to my search criteria.
after that i add my personal “and” statement.So that looks fine.
i also checked that surpress_filters is not active and checked that the filter its used
in the ./wp-includes/query.php all looks good – but it has no impact on the result…as i said – i can write total nonsense in the $where, and the search is triggered
as if i nothing happens.thats why i think that i put the trigger to late, and the query is already executed ,
is this possible ?i checked the posts_requests filter, and that is also funny.
i inserted that code in my functions.php
function my_posts_request_filter( $input ) { print_r( $input ); } add_filter( 'posts_request', 'my_posts_request_filter' );and i get
“SELECT * FROM wp_posts WHERE 1=2”so this does’t look like my query 😀
and also here if i change that code to this:
function my_posts_request_filter( $input ) { global $wpdb; $input = "SELECT * FROM wp_posts where ".$wpdb->posts.".ID is in (1,2,3) "; print_r( $input ); } add_filter( 'posts_request', 'my_posts_request_filter' );it has no impact on my search result. I get the same posts, as if this filter would not be in the code.
Forum: Hacks
In reply to: posts_where filter is ignoredHey folks,
me again.Ok even if i make a clear sql error in the statement, i get a result…
$where .= " AND ".$wpdb->posts.".IDXAXAXAXA is in (1,2,3) ";so thats at least the prove that my filter is ignored… but why ?