开发者

Override Buddypress function to change SQL conditions

开发者 https://www.devze.com 2023-02-09 07:21 出处:网络
I’d like to add condtions to the bp_forum_topics() loop that only contain posts with certain keywords. Can anyone help me with this?

I’d like to add condtions to the bp_forum_topics() loop that only contain posts with certain keywords. Can anyone help me with this?

I’d like to create a custom plugin that overrides the current function bp_forum_topics() that does this. Im new to wordpress development so unsure about filters and tags. Right now it returns all topics (with the exception of loose search terms, newest, popular etc). I want to be able to return topics if the posts related to that topics contains specific search terms.

I can manage the coding for this, but what i'm unsure about is ov开发者_如何学JAVAerriding the bp_forums_get_post functions while still retaining the other functions used in buddypress, such as get_avatar.

Any help would be great.

Mark

UPDATE: Here is the SQL

SELECT
  post.post_id,
  post.topic_id,
  topic.topic_title,
  post.post_text
FROM bb_posts post
LEFT JOIN bb_topics topic
  ON topic.topic_id = post.topic_id
WHERE topic_title LIKE '%searchterms%' OR post_text LIKE '%searchterms%';


Glad to see you've found the solution. You should put the SQL as an answer.

SELECT
  post.post_id,
  post.topic_id,
  topic.topic_title,
  post.post_text
FROM bb_posts post
LEFT JOIN bb_topics topic
  ON topic.topic_id = post.topic_id
WHERE topic_title LIKE '%searchterms%' OR post_text LIKE '%searchterms%';
0

精彩评论

暂无评论...
验证码 换一张
取 消