Is there a better way to programmatically insert content into a page?
Is there a better way to programmatically insert content into a page?
Prevent Duplicate Attachment When Using wp_insert_post
You can set an image as post thumbnail when it is in your media library. To add an image in your media library you need to upload it to your server. WordPress already has a function for putting images in your media library, you only need a script that uploads your file. Usage: Generate_Featured_Image( ‘../wp-content/my_image.jpg’, … Read more
I found the answer. Actually I was passing the template in the wp_insert_post. When I remove that parameter it returns the post ID. And with that post ID I used add_post_meta( $page_id, ‘_wp_page_template’, ‘tpl-favourites.php’ ); to set the template for that page. It is a common technique. I have just dig the code of a … Read more
Do all insert manually via wpdb (SQL). you can do multiple inserts with one sql statement. the wp_post_meta is very simple built.
Managed to get a working solution. What you need: TinyMCE Advanced plugin What you should do: Customize the Visual Blocks Plugin that comes with the TinyMCE plugin and add css classes for each element you would to highlight (just loop through all p elements and parse the innerHTML and check if it contains your specific … Read more
Is there a better way to programmatically insert content into a page?
Something tells me that it could be the maximum script execution timing out perhaps. The amount of memory your inserts are consuming could also be the culprit. Are you getting any error messages, blank screens or anything like that? You could try adding the following above where you’re calling the wp_insert_post() function: set_time_limit(0);
I asked the same question a while ago. Scribu gave me an answer here. The long and short of it: after you insert your terms, add this line of code. delete_option(“my_custom_taxonomy_children”); Of course, replace my_custom_taxonomy with your own, but leave the _children part.
add_action( ‘publish_post’, ‘run_when_post_published_first_time’,10,2 ); function run_when_post_published_first_time($post_id, $post) { // Checks whether is post updated or published at first time. if ($post->post_date != $post->post_modified) return; // Place here your code } from http://wordpress.org/support/topic/new-post-hook
You can use wp_set_object_terms after the post is saved and in case it fails you will get reason for that ex: $new_lead = array( ‘post_title’ => $lead_name, ‘post_content’ => $lead_message, ‘post_type’ => ‘leads’, ‘post_status’ => ‘publish’, ); $lid = wp_insert_post($new_lead); $status = wp_set_object_terms($lid,$term_id,’lead-status’); Now this does the save but $status will hold the reason for … Read more