Searching on terms.slug
This topic contains 11 replies, has 3 voices, and was last updated by Paolo 10 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
December 2, 2014 at 10:27 am #23239
Hi all,
Modifying the core again because seems no other way for it…
Anyway this time im editing function searching_filter_where($where) { found in listing_filters.php
So why am I editing this? because I changed the drop down in my business directory to show all categories because post types is completely useless, then I removed the javascript to auto change to the category when selecting it in the drop down but it remains useless and the default search doesn’t take category into account in searches so thats why I am there.
Anyway I see that searches are done by direct mysql queries and I have modified as follows to search by the name of the slug it doesn’t seem to work and I have tested the new part I added in mysql workbench as working fine for retrieving all post id’s
$where .= "AND (($wpdb->posts.post_title LIKE "%$s%" $better_search_terms) OR ($wpdb->posts.post_content LIKE "%$s%") OR ($wpdb->posts.ID IN( SELECT $wpdb->term_relationships.object_id as post_id FROM $wpdb->terms, $wpdb->term_relationships WHERE $wpdb->term_relationships.term_taxonomy_id = (SELECT $wpdb->terms.term_id FROM $wpdb->wp_terms WHERE $wpdb->terms.slug = "$thecat") ) ) AND $wpdb->posts.post_type in ('$post_types') AND ($wpdb->posts.post_status = 'publish') ";
Anyone got any idea?
/inb4 you shouldn’t modify the core….
December 2, 2014 at 10:33 am #23240Modified the start of that bit just now to select distinct because I don’t see the sense in selecting all as it adds a lot of ID’s to the array.
SELECT DISTINCT($wpdb->term_relationships.object_id) as post_id
December 2, 2014 at 10:54 am #23244Also when logged this is whats returned from that function:
AND (t( wp_posts.post_title LIKE "%%" ) ntttttttOR ( wp_posts.post_content LIKE "%%") ntttttttOR ( wp_posts.ID IN(tntttttttttSELECT distinct(wp_term_relationships.object_id) as post_id n FROM wp_terms, wp_term_relationshipsn WHERE wp_term_relationships.term_taxonomy_id = (SELECT wp_terms.term_id FROM WHERE wp_terms.slug = "it-communication")n ) ntttttt) nttttt) nttttAND wp_posts.post_type in ('gd_place') nttttAND (wp_posts.post_status = 'publish') , referer: http://visitfraserburgh.com/?geodir_search=1&stype=gd_place&scat=it-communication&s=+&snear=&sgeo_lat=&sgeo_lon=
Do the line breaks etc get stripped out before running? Don’t see why that would be an issue as the others are the same and work, just trying to find something that could be an issue.
December 2, 2014 at 7:20 pm #23305HI Boxportable,
I’ve flagged this for Stiofan. He’s the only one who can answer, but you’ll have to be a bit patient, cause we are in the middle of polishing the new versions for next week release and he’s particularly busy.
Thanks
December 3, 2014 at 8:32 am #23367Why is this marked as resolved though? I mean fair enough hes looking at it when he can but its not resolved as yet.
Also thanks for flagging this.
December 3, 2014 at 4:00 pm #23399Hi,
I meant to mark it as “not a support question”. My mistake.
Thx
December 8, 2014 at 10:52 am #23793Anyone any ideas on this while I wait for Stiofan?
Clients website is launching tomorrow so it would be nice to have some feedback on this within the next week or so if anyone else has any ideas about the issue.
December 11, 2014 at 11:16 am #24060Anybody anything they can add to this while I wait on Stiofan to look?
December 11, 2014 at 4:41 pm #24090Hi, have we not had this discussion before?
And yes you should NEVER mod core! 🙂
I assume you are talking about the search bar widget GD > Search though you did not say it specifically. Why are you modding core queries? If it was me i would copy that widget and mod it as i need, you can create your own cat dropdown and add it to the query something like
&sgd_placecategory=2
If you explain clearly what you are trying to do rather than what you have done we might be able to advise you better.
Thanks,
Stiofan
December 12, 2014 at 8:43 am #24164> I assume you are talking about the search bar widget GD > Search though
Well I modified the way that worked and I don’t think its a widget, you can see the website here: http://visitfraserburgh.com/places/ as its now gone live.
The drop down to the left of search shows a list of categories, to do this I used the following function from this thread: https://wpgeodirectory.com/support/topic/changing-post-type-dropdown-filter-to-categories-drop-down/
The search function which I mentioned in the first post in this thread is supposed to search on category, as I said in the first post I am trying to modify the search to search by category.
Testing my modified query in the likes of mysql workbench will bring back the correct results so I am curious as to why it doesn’t in wordpress.
Also I don’t understand you mentioning: sgd_placecategory as a GET var it doesn’t seem to do anything, I have used scat=’Category Slug’ as my get var and the modification in the first post of this thread to the search query will search based on this and will get post ID’s based on the terms.slug matching the term_taxamony_id.
I would not find it difficult to understand what I have explained already in this thread so I am unsure why you have asked me to “clearly” explain myself surely you must have wrote the search function and can see just by looking at what I have in the first post, what I am trying to do with it, I didn’t even write your search function and could see what the function was doing.
December 15, 2014 at 9:00 am #24342I take it no one including the developer can explain why the perfectly reasonable modification to the cores search function I made doesn’t work in practice but does in SQL workbench, starting to think you freelanced much of the plugins code out to others.
Seems fairly obvious you can’t answer basic questions about the search function in plugin you “apparently” wrote, seems I would of been far better off using my own custom post type with advanced custom fields to achieve what this over bloated plugin is doing, at least could of used WordPress’s own meta queries rather than the hotch potch way you have done the search code.
Thanks again for the practically useless but expected response Stiofan.
December 15, 2014 at 6:00 pm #24395This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket