index pdf contents of custom post type

Home Forums Product Support Forums Ajax Search Pro for WordPress Support index pdf contents of custom post type

This topic contains 9 replies, has 2 voices, and was last updated by gendalone gendalone 4 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #23079
    gendalone
    gendalone
    Participant

    Hello,
    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.

    #23085
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23089
    gendalone
    gendalone
    Participant

    Thanks 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.

    #23096
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23388
    gendalone
    gendalone
    Participant

    Hi 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.

    #23397
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23398
    gendalone
    gendalone
    Participant

    Hi 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….

    #23471
    gendalone
    gendalone
    Participant

    Hi 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

    #23475
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #23496
    gendalone
    gendalone
    Participant

    Thank 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.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.