• I’m not sure if this is getting posted in the correct place, if not, my apologies.

    I was wondering if it’s possible on a WordPress site to detect .mp3 files (or any files type actually) and add a class automatically using the functions.php

Viewing 4 replies - 1 through 4 (of 4 total)
  • Add a class to what?

    Thread Starter br0wnie91

    (@br0wnie91)

    Sorry, the link, so when an .mp3 is uploaded to a post you get

    <a href="..../mymp3.mp3">mymp3.mp3</a>

    I want to add a class to the link so you end up with

    <a href="..../mymp3.mp3" class="myclass">mymp3.mp3</a>

    Uploaded? Or inserted into a post? The former is pretty much impossible as far as I am aware. The latter could be done via your theme’s attachments.php template file using get_post_mime_type. Have a look at the example on that Codex page.

    Thread Starter br0wnie91

    (@br0wnie91)

    Thank you for your response esmi but I ended up using Advanced Custom Fields to create a file upload area on the admin then when it’s echoed out in my theme I just add the class there.

    Thanks again

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Detect file type and add class’ is closed to new replies.