logo
down
shadow

wp all import script to custom post image gallery


wp all import script to custom post image gallery

By : Edward Adams
Date : November 28 2020, 09:01 AM
this will help (UPDATE) after much time spent learning php I have found a solution.....
THE ANSWER: 30 Nov 2015 - I found a way to do this and I hope it helps someone. You have to make sure that images that you are testing with have produced attachments otherwise it will obviously not work. I have forced it and fixed that problem by setting plugin WP ALL IMPORT to rename images as it uploads them different then it was previously, so it created new attachments. good luck!
code :
<?php
//This hook is called after WP All Import creates/updates a post      attachment file(s).
add_action('pmxi_gallery_image', 'update_images_meta', 10, 3);
function update_images_meta($pid, $attid, $image_filepath)
{

$attachments = get_children(array(
    'post_parent' => $pid,
    'post_type' => 'attachment',
    'post_status' => 'inherit',
    'order' => 'ASC',
    'post_mime_type' => 'image'
));

//print_r($result);
$atts = array();
// Fill the array with attachment ID's

foreach ($attachments as $attachment) {
    array_push($atts, array(
        "image" => "$attachment->ID"
    ));
}

//echo '<pre>'.print_r($attachments,true).'</pre>'; //for testing
//echo '<pre>'.print_r($attachment,true).'</pre>'; //for testing

// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'update_images_meta', 10);

// Update the post's meta field with the attachment arrays
update_post_meta($pid, 'accommodation_images', $atts);

// renable save post action
add_action('save_post', 'update_images_meta', 10);

}
?>


Share : facebook icon twitter icon
Android, How to add title (a custom view) into each image item of Gallery (from gallery adapter)?

Android, How to add title (a custom view) into each image item of Gallery (from gallery adapter)?


By : Suzana Sharma
Date : March 29 2020, 07:55 AM
Advanced Custom Fields + Gallery Field - Show First Image from the Gallery

Advanced Custom Fields + Gallery Field - Show First Image from the Gallery


By : Matthew Pesonen
Date : March 29 2020, 07:55 AM
How to delete image from my Custom gallery and then Refresh the gallery

How to delete image from my Custom gallery and then Refresh the gallery


By : Dzulfan Fadli
Date : March 29 2020, 07:55 AM
Display all post image gallery using the shortcode [gallery]

Display all post image gallery using the shortcode [gallery]


By : Shahroxe khan
Date : March 29 2020, 07:55 AM
seems to work fine I found the solution, so I share this with you. Maybe someone will be interested by that.
I modified the following code :
code :
$post_content = $post->post_content;
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
$array_id = explode(",", $ids[1]);
<?php
global $post;

    $post_content = $post->post_content;
    preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
    $images_id = explode(",", $ids[1]);
echo do_shortcode('[gallery type="slideshow" ids="'. implode(',', array_slice($images_id, 0, 3)).' ,"]');
?>
How can I import an image from gallery and replace the one that in image view?

How can I import an image from gallery and replace the one that in image view?


By : Pedro Martins
Date : March 29 2020, 07:55 AM
Related Posts Related Posts :
  • Simplify a multidimensional array in PHP
  • Dynamic DB login in TYPO3 extension
  • Missing index in a multidimensional array PHP
  • output data based on two tables
  • Populate form from database
  • Got blank value in update query
  • PHP show message based on user had attach file or not attach file
  • Outline a transparent image using imagick PHP
  • If statement based on last digit of php variable number
  • make popup when post data on the same page
  • How to check email id's with specific domain from the array of email id's in PHP?
  • Dropdown list displays no value
  • Change openssl version in MAMP
  • How to use ob_start() in PHP project while using of Front Controller pattern
  • How do I implement search filter query using mongodb?
  • Android retrieve data from php org.json.JSONArray cannot be converted to JSONObject
  • Error Get request PHP
  • Update datepicker value based on php condition
  • Codeigniter Model loading error
  • How to sort varchar id on basis integer in it using mysql
  • Trial Balance Update accounts
  • Always return user details as json every time user login in laravel 5
  • join table on postgres with php
  • How to check for empty values with in_array WITH EXCEPTIONS?
  • How to replace return carriage in json string made from mysql and php?
  • Intl extension not getting loaded
  • PHP How to echo a 3-dim array
  • How to extend and modify a vendor model in Laravel 5?
  • How to change the number of posts that Wordpress JSON Api loads per page
  • how to validate dynamic text boxes using jquery
  • PHP undefined index id error
  • How to Parse xml data using php
  • getJSON parser cannot process JSON output from PHP file
  • Using Redis on Azure with Symfony2
  • php proc_open file descriptor in bash command
  • Trying to create a generalized function in PHP 5.2, error message not showing
  • Merging multiple rows with same field in column
  • Move "in stock" up on Woocommerce product page
  • Wrong reference path to Mail.php
  • phalcon volt bitwise operatios?
  • How to switch between tab when form submitting in same php file?
  • Storing a single password within in a PHP file instead of a database of users
  • get increment decrement day once clicked button
  • sql check for duplicates returning bool false?
  • Webmaster tools api dimensions
  • Seeding table using model factory not saving
  • How do I save associated entities in Doctrine 2?
  • fopen $_SERVER[REQUEST_URI]
  • RedBean One to Many Attribute Not Working
  • Safely passing ids to form action?
  • Php array explode a char
  • PHP MySQL Login Failure
  • can't get file_exists to work
  • Array PHP, Check if exist multiple elements to another array
  • Can array_walk be nested in php?
  • Notice: Use of undefined constant DIR - assumed '_DIR_'
  • Getting a weird 500 error with ajax
  • How can I filter an array of strings to remove elements that are prefixes of other elements?
  • Duplicate entries when assigning custom id to Laravel Model
  • AJAX call not returning php file command
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co