0

I've got a client with some very specific requirements for a feature on their WP site for a downloads system. After a lot of scouring of the web I've found an old plugin and made a few changes to improve the styling and visual output.

The plugin now does 90% of what is needed. However, it stores its data in 2 custom table that are specific to only this plugin. It does not use the posts table or any other WP table. This means that the content derived from the plugin is not searchable via WP's built in functionality, and there doesn't seem to be any logical means to rectify this.

As a result, it seems my only option is to try and convert the plugin so that is uses custom posts to store the data related to the downloads.

Im fairly new to WP and a bit rusty on my PHP, so I could really do with some help / pointers of how to best go about solving the search issue.

Here are the details of the tables....

TABLE: wp_download

COL1: id

COL2: category_id

COL3: name

COL4: description

COL5: url_file

COL6: image

COL7: hits

COL8: created(datetime)

COL9: modified(datetime)


TABLE: wp_category

COL1: id

COL2: name

COL3: description

COL4: image

COL5: created(datetime)

COL6: modified(datetime)


Essentially, I looking for clarification of how this data would be re-distributed to be better integrated with WP and therefore searchable.

For example.. What data, goes where? Do I need to create custom post types etc?

Thanks in advance, any help will be greatly appreciated.

1

There is the post type attachment, which is normally used to store information about files uploaded to WordPress' Media Library. Additional data can be saved into custom fields/postmeta. You definitely should look into that, if you decide to go with native WP tables.

Another possibility would be to make those custom tables searchable, on the codex page »Custom Queries« you find an example about »Keyword Search in Plugin Table« which should get you started.

  • I tried the 'Keyword Search in Plugin Table; but that doesnt seem to do anything. Based on that, perhaps some ignorance on my part, that section now reads to me as saying that you still need to have the main data as a post in the post table, and that your ancillary info in the custom table. Then you can do an SQL JOIN to grab the ancillary data for your posts. In my case their are no posts as such. ALL my data is stored in a custom table and are distinct from POSTS. – Phill Healey Aug 12 '14 at 9:10
  • 1
    Like I said, it should get you started, especially regarding available filters/actions/hooks, never promised a ready-made solution, so to make it work for you, you have to fit it to your needs. Another informational resource you should/could look into is the question How to extend WP_Query to include custom table in query? on here. @PhillHealey – Nicolai Aug 12 '14 at 9:33
  • 1
    You probably want to take a look into the source, the main one would be /wp-includes/query.php. Here is a search query for »posts_« on »hookr.io«, because there are more hooks than the example shows. @PhillHealey – Nicolai Aug 12 '14 at 9:46
  • Thanks for the additional references, Ill go take a look. Thanks again. – Phill Healey Aug 12 '14 at 12:34
  • I know how SO works! I tend to mark questions as answered when I'm sure my question has been answered by one of the 'answers', and not when Im told to accept an answer. But thanks for your answer. – Phill Healey Aug 14 '14 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.