Support » Plugin: Easy Digital Downloads - Simple eCommerce for Selling Digital Files » How can I add custom fields to the posts?

  • Resolved kirasiris

    (@kirasiris)


    I normally create custom fields by doing the following in my functions.php file:

    
    function preview_link($postID){
    	$demo_url = 'preview_url';
    	$demostracion_url = get_post_meta($postID, $demo_url, true);
    	if($demostracion_url==''){
    		delete_post_meta($postID,$demo_url);
    		add_post_meta($postID,$demo_url, '#');
    		return '#';
    	}
    	return $demostracion_url;
    }
    

    after this I will just need to type it in the custom field metabox(which does not even appear) in order to use it but for some reason I can not get it to work; I really need this as I’m creating a theme in which client will sell templates and needs a link to showcase the demo.

    Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Pratik Jain

    (@pratik-jain)

    Hi @kirasiris

    Can you please explain a little more what you want to achieve with this?

    Are you getting some info at product single page of Easy Digital Downloads?

    Thread Starter kirasiris

    (@kirasiris)

    I’m so sorry for the late answer. I’m trying to create a link to showcase the demos of the themes being offered to sell.

    For example,
    https://bootstrapwp.com/themes/strappress/ …. not my website

    if you hover over the image, you can see a button re-directing to a different page. I’m trying to create that and since I’m not using the Advanced Custom Fields plugin, the code I posted in my original post is how you add it manually but for some reason it does not show any meta box for custom fields in the EDD cpt.

    Pratik Jain

    (@pratik-jain)

    Hi @kirasiris

    You are talking about the built-in WordPress Custom Fields Metabox right?

    Please refer below screenshot so you will be more cleared.
    https://screenshots.firefox.com/swN3MlIGurxGQweV/192.168.1.53

    Pratik Jain

    (@pratik-jain)

    Hi @kirasiris

    Have you checked my provided screenshot?

    Thread Starter kirasiris

    (@kirasiris)

    I’m so so sorry for the late answer, I;ve not checked this website in 5 days!. Yes, that’s exactly what I mean!.

    Pratik Jain

    (@pratik-jain)

    Hi @kirasiris

    Please add below code snippet to your current theme functions.php file. It will start displaying Custom Fields meta box.

    add_post_type_support( 'download', 'custom-fields' );

    Thread Starter kirasiris

    (@kirasiris)

    That’s exactly what I needed, thanks dude!!. I’m not used to add supports to CPTs in that way so I was unaware of that!.

    I will mark the question as solved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How can I add custom fields to the posts?’ is closed to new replies.