WordPress.org

Ready to get started?Download WordPress

Forums

MimeTypes Link Icons
Using mimetypes-link-icons outside loops (4 posts)

  1. pauro
    Member
    Posted 2 years ago #

    Hi, just found this plugin recently and it works great inside loops.
    I just want to know, is there any chance I can use it outside.
    I want to show download links, with mime icons on sidebar.
    My existing code is:

    <?php
    $args = array(
    	'order'          => 'ASC',
    	'post_type'      => 'attachment',
    	'post_parent'    => $post->ID,
    	'post_mime_type' => 'application',
    	'post_status'    => null,
    	'numberposts'    => -1,
    );
    $attachments = get_posts($args);
    if ($attachments) : ?><h3 class="widget-title"><span>Attachment files</span></h3> <div class="widget"><ul>
    <?php	foreach ($attachments as $attachment) {
    
    		echo '<li>', the_attachment_link($attachment->ID, 'files_attachment', true, false), '</li>';
    	} ?>
    </ul></div>
    <?php endif;?>

    This code works but it will be better if it shows icons and file sizes.

    p

    http://wordpress.org/extend/plugins/mimetypes-link-icons/

  2. eagerterrier
    Member
    Plugin Author

    Posted 1 year ago #

    @pauro sorry for late response. Developers don't get notified of new posts to the forum. I have to check periodically to see if there's anything new.

    I'll have a look at your code and have a think. My first thought is that we could do something for you on a one off basis with jQuery...

  3. meganlop
    Member
    Posted 1 year ago #

    Hello there. First of all I also want to let you know that you did a great job. I really like this plugin.

    Unfortunately for me it's the same than for "pauro": I am not able to get it working with links outside the loop.

    I use it in combination with the Plugin "Attachments" and it works perfectly inside content-area. But when I put downloads i.e. into the sidebar, these documents don't get their icon.

    Maybee you can catch up with that in one of the next versions? I would really appreciate that. :)

  4. eagerterrier
    Member
    Plugin Author

    Posted 1 year ago #

    @pauro / @megalop

    I think @megalop has come up with a good solution here.

    I tried thinking of a way to get the plugin to work outside the loop on an ad hoc basis, but couldn't find a decent way of doing it.

    Perhaps the solution is this:

    1. Have a text entry field in the admin area that will ask for selectors that you want targeted - ie #mysidebardiv or .attachments

    2. These selectors are passed to the front end. Jquery will asyncronously process these to give us the nice links we require

    Questions:

    a). Does this make sense?

    b). Do we all think this is an acceptable solution?

    Let me know within the next couple of weeks. I'm planning a new version of the plugin before the end of June / beginning of July

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic