How to share same post to multiple site in wordpress?

You can use the function switch_to_blog() for this $other_id = 1234 // the id of the other blog to save the post to switch_to_blog($other_id); $my_post = array( ‘post_title’ => $post_title, ‘post_content’ => $post_content, ‘post_status’ => ‘publish’, ‘post_author’ => $post_author, ); // Insert the post into the database wp_insert_post( $my_post ); restore_current_blog(); There is a pitfall … Read more

get_terms parent for current product only

get_terms relates to getting all the terms of a taxonomy. get_the_terms grabs all the terms related to the post. The problem is that it sounds like you only want to return those terms which are parent categories, not the children, and get_the_terms does not pass an arguments array. $terms = get_the_terms( get_the_ID(), ‘product_cat’ ); foreach … Read more

problem to delete page

This is attachment, you can find it in the Dashboard > Media menu. which id is: 497, you can find it and delete it. As I can see in Inspect element this is image: http://capptan.com.br/blog/wp-content/uploads/2018/07/engajar-e-reter-usu%C3%A1rios-de-aplicativos.jpg But in your template, I can see you have hidden these things via CSS. Hope you know how to delete … Read more

Can’t publish, edit or delete posts since Gutenberg update

This is most likely a plugin or theme conflict in one way or another. Here’s the steps I’ve taken when troubleshooting Gutenberg-related issues: In a staging environment, deactivate all plugins — posting should work as intended now. If it doesn’t then the issue is more likely a theme conflict. 1.a. If it’s a theme conflict, … Read more

How do I programmatically add an image to a post?

Hey I used this code for something similar(I was also downloading remote image and uploading to WordPress site). Please have a look: $image_url = $value;//This is the sanitized image url. $image = pathinfo($image_url);//Extracting information into array. $image_name = $image[‘basename’]; $upload_dir = wp_upload_dir(); $image_data = file_get_contents($image_url); $unique_file_name = wp_unique_filename($upload_dir[‘path’], $image_name); $filename = basename($unique_file_name); $postarr = array( … Read more

Embed WordPress Admin in an iframe

By default WordPress doesn’t allow to embed the admin pages into a frame. From wp-includes/default-filters.php: add_action( ‘admin_init’, ‘send_frame_options_header’, 10, 0 ); To enable embedding, remove the action in a plugin: remove_action( ‘admin_init’, ‘send_frame_options_header’ ); Be aware of the security implications. I wouldn’t do that.