How do I add Facebook OpenGraph meta tags for attachments in the header for a custom theme?

$attachment_id is simply the numerical ID assigned to any media you have uploaded. You can write: echo wp_get_attachment_image(‘1′,’large’); to display the large size of image attachment with ID of 1. You should setup a new query to get all of the attachment IDs associated with the current post, then you can get_posts(‘post_type=attachment’) Check this example … Read more

How to link images to attachment.php [duplicate]

I am not sure what you mean by “redirect” there. attachment.php is meant to be used as theme template file. Loading it directly it won’t be able to access WordPress core properly. In usual WordPress mechanics you can use get_attachment_link() to form URL itself or wp_get_attachment_link() for whole link HTML.

Insert attachments from front end form

I found a working solution. This handles the uploaded files by attaching them to the post and display them in the loop. Still no featured image is set. if ( $_FILES ) { foreach ( $_FILES as $file => $array ) { $newupload = insert_attachment( $file, $pid_buy ); } } function insert_attachment( $file_handler, $post_id, $setthumb=’false’ … Read more

missing attachment are showing as 404

Although I see this question not specific to WordPress (at least the answer it’s not), I see similar questions posted in a regular basis and I think it is good to give a answer. If a URL doesn’t exist, in your case the URL is for a non-existant attachment, 404 is the correct HTTP status … Read more

When inserting attachments into a blog post, how can I get WordPress to use the full filename with the extension?

I figured out how to retitle the attachment myself, using a combination of the answers from these two posts: How can I add a default description to uploaded files? Change attachment filename Here’s the code, it’s working on my current WP installation (v4.3) function wpse_retitle_attachment( $post_ID ) { $file = get_attached_file($post_ID); $path = pathinfo($file); $args … Read more

Retrieve ONLY mp3s and set a variable for use in a playlist called by single.php template?

So here’s what I did to resolve this… I inserted the following code right after the loop started: <?php global $post; if( is_singular() && is_main_query() && $post->post_type === ‘download’ ) { $download = new EDD_Download( $post->ID ); $files = $download->get_files( ); $submission_attachment_ids=””; if ( is_array( $files ) ){ $first = true; foreach ( $files as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)