• I’m using a file field and no matter what I try, it only outputs the raw URL;

    types_render_field("downloads", array("title" => "read me..."))

    This outputs nothing

    echo do_shortcode('[types field="downloads"][/types]');

    This outputs a raw, unseparated string of URLs, not links as the API says it will

    echo do_shortcode('[types field="downloads" title="read me..."][/types]');

    This outputs a raw, unseparated string of URLs. Title argument is ignored.

    echo do_shortcode('[types field="downloads" ouput="raw"][/types]');

    This outputs a raw, unseparated string of URLs, same as the top two.

    As you can see, none of these output links! All I’m getting are raw strings of URLs no matter what I try. This isn’t a problem with image fields, only the file field.

    I have tried ‘output’=>’html’ argument and it wraps each raw string in a div>span. Again no link, I don’t want to have to resort to separators unless I really have to as this won’t let me have the file name as the link text. (Obviously I wouldn’t want the full URL as the link text).

    Any help is greatly appreciated.

    Thanks.
    Kyle

    https://wordpress.org/plugins/types/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Beda

    (@bedas)

    The File Field does display a file upload dialogue and provide a link to the file on your site.

    Therefore, it will display a link to an uploaded file or the URL of the file.
    https://wp-types.com/documentation/functions/#file

    To render Types fields you do not use do_shortcode, but Types API or echo a get_post_meta value.

    Types API Example (found in above DOC)
    echo types_render_field("my-file", array("title" => "read me..."))

    Your code does not output anything because you do not echo the value.

    Thread Starter krwetton2014

    (@krwetton2014)

    Thanks for your reply but I think we may be confusing eachother. What I’m trying to do is NOT out put just the URL. I am using ‘allow multiple instances’ so this obviously doesn’t work. I don’t wan’t do use a separator argument in the array because it’s a link, so there is no way to set what the link TEXT will be. I don’t want the full URL as the link TEXT.

    What I’m trying to point out is that your API (that you have linked me to) is incorrect, this example here

    [types field="my-file"][/types]
    Will generate the following
    <a href="/path-to-my-file/my-file.pdf" title="/path-to-my-file/my-file.pdf">/

    Is incorrect, and because again I am using ‘allow multiple instances’, I need EACH instance to be given both the title and the href, but again all the above code does it output every files string in a non-separated string.

    Please test for yourself, and thanks for the help.

    Also, I use do_shortcode for other fields when appropriate, why doesn’t it work for the file field specifically?

    Plugin Support Beda

    (@bedas)

    The Problem with repeating fields is that a given value (title as example) will repeat for all fields.
    Let’s see that on this example:
    the URL of the field (repeating) is each time inserted to the Field, therefore unique.
    Then if you use the Types GUI, you would minimally produce this:
    [types field='url' title='Title' separator='&nbsp;'][/types]

    That produces the correct links, b ut always “Title”
    So to have different Titles the only way is Custom Code, which i can not provide, or, using Views and iterate with a for-each shortcode the Field’s repetitions and output another repeating Field as title.
    Views is a paid plugin though, and I can not instruct here how to use it.
    You could consult us here abou this. First you need to (free) register.

    According this you should be able to use an index attrubte as in:
    [types field='url' index='1'][/types]
    (to address a single item a time)
    But, in my tests this did not work.

    Can you confirm this BUG?
    Because if that works, you can create each output singularly and hereby address each title as per your needs.

    Thread Starter krwetton2014

    (@krwetton2014)

    Thanks Beda, the issue is that it’s not even creating the html around the string.

    Here’s an example. Say our website is called awesomesauce.com.

    Say we are uploading files. FileA, FileB, FileC and FileD.

    Now, we use this exactly as you’ve written.

    [types field='url' title='Title' separator=' '][/types]

    This is what is outputted
    http://awesomesauce.com/wp-content/uploads/2016/07/FileA.pdfhttp://awesomesauce.com/wp-content/uploads/2016/07/FileB.pdfhttp://awesomesauce.com/wp-content/uploads/2016/07/FileC.pdfhttp://awesomesauce.com/wp-content/uploads/2016/07/FileD.pdf

    Now the above string of URLs is what I get regardless of whether I use shortcodes or not, whether I add any arguments in the array or not.

    It doesn’t wrap it with an ‘a’ tag, it doesn’t include any Title let alone the same one, it doesn’t include link text, it doesn’t do anything useful.

    I have managed to use child posts as a different way of addressing this issue, but thought it’s worth bringing it up. Thanks for looking into it for me.

    Plugin Support Beda

    (@bedas)

    Well, this does not happen on my end.

    So that means, it is a usage issue or a compatibility issue.

    And to analyse that we must proceed with more information which I can not request here in the forum.

    Please contact us in the dedicated forum.
    It is free.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Type Field: File – Outputs raw url only?’ is closed to new replies.