Add a image uploader in the posts page backend

For custom fields in the backend (like an extra image or extra text) in a post backend we are using Advanced custom fields. This is for us the most easy way to add extra variables to the backend. They also have a function especially for images or a gallery. In your theme you can use … Read more

Troubles with code for upload a image

well i look and i look and finally i found this work that work for me. $upload = wp_upload_bits( $_FILES[‘image’][‘name’], null, file_get_contents( $_FILES[‘image’][‘tmp_name’] ) ); $wp_filetype = wp_check_filetype( basename( $upload[‘file’] ), null ); $wp_upload_dir = wp_upload_dir(); $attachment = array( ‘guid’ => $wp_upload_dir[‘baseurl’] . _wp_relative_upload_path( $upload[‘file’] ), ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename( $upload[‘file’] … Read more

Limit attachment caption characters

do you have a custom meta field associated with the image? if so place this in your functions.php: <?php $trim_length = 21; //desired length of text to display $custom_field = ‘your custom field key here’; $value = get_post_meta($post->ID, $custom_field, true); if ($value) { echo ‘<p>I want to use: ‘ . rtrim(substr($value,0,$trim_length)) . ‘…</p>’; } ?> … Read more

How to get attachements URL from author meta and display them?

I found it 😀 Yeeeeeeeeaaaahhhhhh :)))) This is final code that worked! I explained each level 😉 /* for get author ID use these */ $curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author)); $author_id = get_the_author_meta(‘ID’); /* First condition */ if( get_the_author_meta(‘management_certi’, $author_id, true)) { /* get file ID */ $id = get_user_meta( $author_id, ‘management_certi’); … Read more

How to get images to show in Media when saved Via PHP

The Add From Server plugin actually was my answer. I just didn’t know how to use it when I ran across it at first. When you click or hover on the WordPress Dashboard on the left over ‘Media’ you will see ‘Add From Server’ navigate through your directories and choose which file(s) you’d like to … Read more