• Can’t seem to figure out how to get PDF documents to appear in the search results. These are documents placed on page with shortcode or directly linked to from within a page or post. Documents also have media tags. Thanks, Kevin

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Check “Index attachments”, and the any PDF files you have added to posts should appear. Relevanssi doesn’t index the contents of PDF files (or any other attachments), though.

    Hello,
    I have the same problem as Mr. ktsparkman.
    I tagged six files with the same tag and the shortcode outputs 6 bullets, but no content; just a column of 6 bullets.

    I am using WP 3.3.1

    I think the answer of msaari is irrelevant. Its related to Relevanssi ??

    All, I’m the developer of the Media-Tags plugin. I’m trying to understand the exact issue. part of the thread comments here mentioned Media Tags but also related to search. So not 100% sure this is related to me plugin.

    I’ll be glad to provide some help is someone wold explain the issue. Thanks

    Hi, I beleive I have experienced the same issue. I have installed the media tags plugin and tagged 9 files with the tag “Newsletters”. These files are all PDFs.

    When I visit the url media-tags/newsletters the files are listed correctly.

    But when I use the shortcode [media-tags media_tags=”Newsletters”] in a page content I get a list of 9 li’s with no visible content. In fact the HTML contains img tags with src=””.

    The problem is the default_item_callback function assumes the item is an image so it doesn’t work for PDF’s.

    I had to use a shortcode with a custom callback function such as [media-tags media_tags=”Newsletters” display_item_callback=”my_media_tag_display_function” ]

    I can provide the code I used for the custom function if that helps.

    And thus is the power of the custom callback function. I’m working on some other changes to the Media-Tags codebase. I’ll check the short code callback function to ensure it works for non-images.but this will be a while.

    @espprojects

    I would appreciate it if you could provide the custom function to display PDF files.

    Alternatively, how would I get just the link to the PDF files within a media tag to display as a list?

    Just for reference, this was what I tried:

    function my_mediatags($post_item)
    {
    	$file_src = wp_get_attachment_url($post_item->ID);
    
    	return '<li class="media-tag-list" id="media-tag-item-'.$post_item->ID.'"><a
    		href="'.$file_src.'">'.$post_item->post_title.'</a></li>';
    }

    But it just comes back with ‘Array’ instead of a list of the titles.

    Just for reference purposes, I figured out how to display title and link to PDF files using the custom callback function. This is the function I wrote (or rather modified):

    function im_mediatags($post_item, $size='')
    {
    	$image_src 	= wp_get_attachment_url($post_item->ID, $size);
    
    	return '<li class="media-tag-list" id="media-tag-item-'.$post_item->ID.'"><a
    		href="'.$image_src.'" target="_blank">'.$post_item->post_title.'</a></li>';
    }

    This gets the url of the attachment instead of the attachment itself, which is great for PDF files. I wouldn’t know how to alter this to allow a mixture of images and PDF files, though images appear as title and links as well.

    Hi Sabahat –

    Do you know how I an update this code to include the excerpt of items, when using short codes to insert list of items in a page.

    I’ve tried thi, but to no avail (i’m php newbie!)

    function im_mediatags($post_item, $size='')
    {
    	$image_src 	= wp_get_attachment_url($post_item->ID, $size);
    	return '<li class="media-tag-list" id="media-tag-item-'.$post_item->ID.'"><a
    		href="'.$image_src.'" target="_blank">'.$post_item->post_title.'</a></li>
    		<li>'$post_item->post_excerpt.'</li>';
    
    }

    Thanks

    Hey Ladygeekgeek,

    I’m a newbie myself. Most of what I’ve managed to here has been from the WordPress Codex (long live OpenSource!).

    I do know, however, that attachments don’t have excerpts, just captions and descriptions. I think you can get what you need by replacing the function with this:

    function im_mediatags($post_item, $size='')
    {
    	$image_src 	= wp_get_attachment_url($post_item->ID, $size);
    
    	return '<li class="media-tag-list" id="media-tag-item-'.$post_item->ID.'"><a
    		href="'.$image_src.'" target="_blank">'.$post_item->post_title.'</a>	 <br/>'.$post_item->post_content.'</li>';
    }

    Basically, just replace post_excerpt with post_content. You need a full stop before and after the php element, and you will have css and display issues if you put in a second list (li) item, so keep all elements between single li tags. A second li item will make it look like a separate attachment, as each list item will be styled exactly the same as the last. Better to span tags before and after the description in order to style it.

    You are a star!! Works perfectly, thank you so much ??

    Hi. Trying to do the same thing.

    Do you put the function in functions.php or in the template? Or how do you call it?

    Thanks.

    Yes the function should be put in functions.php
    C

    Great.

    Do you short code them on a page, or how do you do it?

    /F

    Yes you can short code them on a page e.g

    [media-tags media_tags="Policy submissions" ?orderby="post_date" order="DES"?display_item_callback="im_mediatags" numberposts="4"?]

    Or you can create a hyperlink to the category page e.g

    <a href="/media-tags/policy-submissions></a>
    C

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘PDFs documents not showing up in results’ is closed to new replies.