Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › index pdf contents of custom post type
- This topic has 9 replies, 2 voices, and was last updated 6 years, 11 months ago by
gendalone.
-
AuthorPosts
-
June 10, 2019 at 11:54 am #23079
gendalone
ParticipantHello,
I would like to know if there’s a way to index pdf content not loaded like media files but loaded under custom post type
(eg. download manager plugin loads its own pdf documents into custom post – not page nor article – and attachments are stored outside media library)Your plugin is able to index custom posts title – text content – excerpt – category and tags but I’m not able to include its attachments into index search.
Thank you in advance for support.
June 10, 2019 at 12:58 pm #23085Ernest Marcinko
KeymasterHi,
I’m afraid that is not possible. I will note this as a possible feature request, I think it should be possible to implement this with only minor modifications on the source code + adding an option for it.
June 10, 2019 at 1:13 pm #23089gendalone
ParticipantThanks for reply,
if source code modification is not too complex, and not too loss-time for you,
I could try to do it on my installation.June 11, 2019 at 8:41 am #23096Ernest Marcinko
KeymasterYou cannot access this content.
June 25, 2019 at 12:31 pm #23388gendalone
ParticipantHi Ernest,
excuse me for disturb,
I understand what kind of work there’s behind coding and I can image you don’t have time to implement my particular feature;
in the meantime, where could I look for into source code to extend pdf index to files not included in media library (eg. file uploaded under download manager)?Thank you for your time.
June 25, 2019 at 2:18 pm #23397Ernest Marcinko
KeymasterHi,
This might be much more complicated than I thought. May I ask which plugin do you use exactly for these attachments? I will have to look into their API, as there is no universal solution to get any attachments related to a certain post, unless it is within the media library. Even worse, if the items are not custom post types.
Indexing Media attachments along with their parent posts could be doable, but when a file is outside the Media library, it becomes a nightmare.Well, the indexing process is a bit complicated, there are multiple files involved. The main file that controls the indexing is wp-content/plugins/ajax-search-pro/includes/classes/etc/indextable.class.php
However I honestly does not recommend modifying that, it could be extremely time consuming.June 25, 2019 at 2:44 pm #23398gendalone
ParticipantHi Ernest,
thank you for quick reply;I’m using wp-download-manager (pro version);
You are right, packages are stored as custom posts (in _posts table), but theis attachments (multiple files in pro version) are stored in _postmeta table, refer to their post_id, with custom meta_keys (__wpdm_files) and with custom meta_value (eg. a:3:{i:1562334567887;s:30:”FILE1.pdf”;i:1563456789376;s:30:”FILE2.pdf”;i:156345353344;s:30:”FILE3.pdf”;}
Here we don’t know custom relative path becouse it is a value stored in _options.
I think that is a very complex case….
June 27, 2019 at 7:47 pm #23471gendalone
ParticipantHi again,
I could have found a workaround but there is a problem with relative link:
I upload pdf files in standard wp media library and index search works fine (in search bar I can find my results)
but results can link to: attachment file, attachment page or attachment parent post.I’ve tried to use another plugin to customize media link, but in this case too, the link is stored in _postmeta table.
If there is a way to use a custom link (and custom image too) should be a valid workaround
(I know that pdf files should be uploaded twice but I don’t see any other solution)Thank you
June 28, 2019 at 7:49 am #23475Ernest Marcinko
KeymasterHi,
Thank you for the previous details, I will look into that plugin API, I already added it to the upcoming features list. It is a pretty decent plugin, I am sure they have an API I can use to get the downloads.
For changing the result URLs as well as image, a custom code should be used. There is this example, based on that, you could try something like this:
add_filter( 'asp_results', 'asp_custom_link_results', 1, 1 ); function asp_custom_link_results( $results ) { // Parse through each result item foreach ($results as $k=>&$r) { if ( isset($r->post_type) && $r->post_type == 'attachment' ) { // $r->id is the attachment ID, in case needed $r->link = 'https://google.com'; // custom link $r->image = https://'myimage.com/image.jpeg'; // custom image url } } return $results; }June 28, 2019 at 10:52 am #23496gendalone
ParticipantThank you very much for reply.
I’ll try to customize your sample function to get custom link and custom image
getting info by $r->id post id into _postmeta table.Hope you will be able to implement attachment index feature with wp-download-manager plugin,
1st becouse that plugin is most used download plugin and 2nd they don’t have plan to develope attachment index feature, so you can be linked by them to use your plugin for search. -
AuthorPosts
- You must be logged in to reply to this topic.