Can’t get post ID using wp_insert_post_data
From the codex page You must pass 2 for the $accepted_args variable in add_filter() if you want to access $postarr. So use this: add_filter( ‘wp_insert_post_data’, ‘set_post_title’, 99, 2 );
From the codex page You must pass 2 for the $accepted_args variable in add_filter() if you want to access $postarr. So use this: add_filter( ‘wp_insert_post_data’, ‘set_post_title’, 99, 2 );
That is because you’re trying to define a property that is already defined, query a table with a wrong name, loop through an integer while you can use get_results instead of query method of $wpdb … I edited the code, hope it will help with your post duplication process: defined( ‘WP_USE_THEMES’ ) || define( ‘WP_USE_THEMES’, … Read more
The wpml_set_element_language_details action element_type need to be with the correct prefix that WPML use: From the WPML Docs element_type(string) The type of an element. Can be a post type: post_post, post_page, post_attachment, post_nav_menu_item, post_{custom post key} or taxonomy: tax_category, tax_post_tag, tax_nav_menu, tax_{custom taxonomy key}. Defaults to post_post if not set. In your case it should … Read more
You can use the page_template filter to load a page template from the plugin directory: function wpd_plugin_page_template( $page_template ){ if ( is_page( ‘namnam-login’ ) ) { $page_template = dirname( __FILE__ ) . ‘/namnam-login.php’; } return $page_template; } add_filter( ‘page_template’, ‘wpd_plugin_page_template’ );
To those who are experiencing the same issue, there are few steps to take to determine the culprit. Create posts manually in the WP Dashboard area (set it to future) .. and manually publish (look for the error in the log). step 1 and trash the post, in the Trash, try reverting that post (this … Read more
For upload from external url you should use media_sideload_image function. I assume $posterurl is url of external image, after wp_insert_post add below code in if($movie_id){} block. It will upload image from external url to this post and if you want to set this image as post feature image use set_post_thumbnail otherwiase comment that line. and … Read more
If you want to create a particular page once, then you can save an option to the database once the page has been created, then check if that value exists before attempting to recreate it. If you store the page’s ID, you can also check if the post still exists and recreate it if it … Read more
Welcome to WordPress SO. You may already have solved the issue as suggested by @Stevish, but just in order to avoid promoting the idea of checkboxes somehow being bad or difficult, I’d like to point out, that they’re perfectly okay and logical. 🙂 What is the problem in your first snippet, is the additional closing … Read more
add_action( ‘admin_menu’, ‘av_subscribe_create_menu’ ); function av_subscribe_create_menu() { $hook = add_menu_page( ‘Add Comment Feed’, ‘Add Comment Feed’, ‘manage_options’, ‘av-create-feed’, // Don’t use __FILE__ as the slug, keep it short ‘n sweet! ‘__return_true’ // We need a callback otherwise WP won’t properly handle the page, though it’s never seen ); if ( $hook ) // Current user … Read more
You can do this by setting the post_parent with the $attach_id. $my_post = array( ‘ID’ => $attach_id, ‘post_parent’ => $my_post_id //retrieved after you inserted your post ); wp_update_post( $my_post ); Just run this after you have both the ID`s of the Post and the attachment, and you have set the parent of the attachment to … Read more