New answers tagged attachments
0
I'm guessing you'll need to fetch the post content and parse it using something like this as a guide (pasted code from above link for future reference).
// Get the all post content in a variable
$posttext = $post->post_content;
$posttext1 = $post->post_content;
// search for the src="" in the post content
$regular_expression = '~src="[^"]*"~';
...
0
Your question is too broad. Break the question down into more specific questions. Then research those questions and bring the unanswered questions to us.
For example, you might break this down into these specific questions.
How do I:
Add a menu item to the Dashboard?
Create an admin options page form?
Submit a custom admin page form?
Page a custom option ...
0
If you look at the $wpdb->posts table in the database, you will notice that the file names, minus the file type ending, are used for the post_title for attachments. This means that you can effectively search the file name if you can get your search function to search attachments, which the default search (almost) already does.
In your code, these two ...
-1
put this code within the loop in single custom post type
$attachments = get_posts( array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'DESC',
'posts_per_page' => -1
) );
if ( $attachments ) {
...
0
A gallery is a post with attached media. So maybe you'll find hints like this : just hook on get_comment_numbers() and pass $attachment_id.
I think in this case you'll have to add an SQL query to get the comment count for attachment and then you'll be able to add it to the total number of comments for post , something like this :
global $wpdb;
...
1
A quick experiment with WordPress 3.5.1 shows that when you an image into post from URL, there's no post inserted into the wp_posts or wp_postmeta table - which is why the $images array is coming back empty.
You could write some JS on the admin side to create and insert a post asynchronously when you click the insert into post button - otherwise, you could ...
1
Ended up using wp_handle_upload(), which puts MIME type into the DB automatically. See http://codex.wordpress.org/Function_Reference/wp_handle_upload
One thing to note, this function enters the file in the DB as post meta and not as an attachment. wp_insert_attachment() would do the latter.
1
The solution, needs a custom control object extending the original image control, and does an SQL query to grab the GUID and associated attachment ID on sanitisation. Not nice, kludgey, but it works
$wp_customize->add_setting( 'customimage', array(
'default' => $default,
'capability' => 'edit_theme_options',
'type' ...
2
You can do it via ajax, first, let's change your current function to this:
<?php
$args = array(
'order' => 'ASC',
'orderby' => 'menu_order',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' ...
0
Saying that images are "attached" to a post has always struck me as misleading. "Attached" implies to me that the images would be associated with a post in some manipulable way. That is the problem. That is not always the case.
Some (many) images are hard coded into the post body. This is what you get when you click the media insert buttons. True, there is ...
0
As far as I know, you'd have to use a combination of built-in functions to achieve this. If there is a plugin, you'd have to research for "Bulk parent" or "Bulk re-attachment".
Unless you have a logic connecting those posts, I think you'd have to do it post by post. Be it with PHPMyAdmin (changing the post_parent column values for all post_type with ...
2
First, exclude the featured image (= post thumbnail) from the query, then set up the posts array as combination of the featured image and the other images.
Put this directly below $args = ... and above $attachments = ...:
if (has_post_thumbnail($post->ID)) {
$featured_image = get_post_thumbnail_id($post->ID);
$args['exclude'] = ...
Top 50 recent answers are included
