• Resolved Swennet

    (@swennet)


    Hello,

    I have a website where users can download episodes of certain series. My issue is however, that I am receiving help with posting from people that don’t have any experience with wordpress, html or php.

    I want them to be able to paste a download link in a custom field. Which will then automaticly add the url to that post.

    Example:

    1. They add the url to the custom field named ‘Download Link’

    2. In my single.php I need the following code (I can’t code php btw)

    <a href="CUSTOM-FIELD-URL HERE">Download <?php the_title(); ?></a>

    How do I do this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • If you are using a free theme, post a link to your site and you may get more help.

    Thread Starter Swennet

    (@swennet)

    I’m using my own theme

    Anime Cube

    Without being able to see your code, I can only give general guidelines.

    Your code should be something like this:

    <?php $url = get_post_meta($post->ID,'Download Link',true);
    if ($url) { ?>
       <a href="<?php echo $url; ?>">Download <?php the_title(); ?></a>
    <?php } ?>

    You should be aware that this might open up your blog to hackers who put malicious code in the ‘Download Link’ field.

    Thread Starter Swennet

    (@swennet)

    @vtxyzzy

    That doesn’t work, it links to the post I put code in.

    EDIT: I copied the code wrong, but copying it right doesn’t work at all.

    Thanks for taking time to try and help me though ??

    Strange – that worked perfectly in my test site.

    Can you post 10 or 20 lines of code around the lines you added?

    Thread Starter Swennet

    (@swennet)

    I just placed it in an existing post to test it. (I have php enabled in regular posts)

    EDIT: I just placed it in my .php file and it worked!

    THANK YOU SO MUCH ??

    You are welcome, but if untrusted users can enter ‘Download Links’, please add some code to edit the entries, or you may have some hacker destroy your site.

    Thread Starter Swennet

    (@swennet)

    I am not having users add links, only people who I create an account for.

    I wish I had a system where users could submit links though.

    You might be able to use TDO Mini Forms plugin.

    Thread Starter Swennet

    (@swennet)

    Thanks I might look into that. Seems like an awful lot of customization to make it work how I want though.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Custom Field auto add download link in post.’ is closed to new replies.