Extending WordPress search

I have a small problem in a wordpress project that I have worked in the past, the solution that I applied there for a custom plugin was to create a couple of tables for some projects that the admin has the ability to add. My mistake was to not make taxonomies and register them in wordpress. Now those projects must appear in the search results. My question is: How/where can I write some code to include a custom table in the search ( where ‘q’ LIKE %title% ) to apply for the internal search and let wordpress calculate the pagination and show the results? Thank you

Related posts

Leave a Reply

1 comment

  1. WordPress had capability to use native mysql query. So you just use the native query to search

    $querystr = "
        SELECT *
        FROM posts
        WHERE post_title LIKE %title% 
        ORDER BY posts.post_date DESC";
    
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    foreach ($pageposts as $post):
      echo $post->post_title;
    endforeach;
    

    About paging, count the row and do paging manually. I think you can do that.