Aimee
Forum Replies Created
-
Forum: Plugins
In reply to: Get first sentence of instagram caption as post title?Solved it, sort of anyway. Used another function instead;
save_post
and it works. However, i’d still like to make this work together with anypreg_
function to fetch the first sentence of the post.add_action( 'save_post', 'save_post_wpse_87921', 10, 2 ); function save_post_wpse_87921( $post_id, $post_object ){ // Auto save? if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; $category = array('photos', 'instagram'); if ( $post_id && !in_category($category, $post_id)) return; $new_title = wp_trim_words( $post_object->post_title, $num_words = 7, $more = '...' ); // Unhook this function so it doesn't loop infinitely remove_action( 'save_post', 'save_post_wpse_87921' ); // Call wp_update_post update, which calls save_post again. wp_update_post( array( 'ID' => $post_id, 'post_title' => $new_title, 'post_name' => '' )); set_post_format($postID, 'image'); add_action( 'save_post', 'save_post_wpse_87921', 10, 2 ); }
Forum: Alpha/Beta/RC
In reply to: Akismet needs upgrade everydaySame problem here. Was the same with 4.1 betas as well.
Any luck with fixing this? I just tried the code again and the posts are still being publicized and sent to social networks.
Forum: Hacks
In reply to: Create a default title based on post format status and or aside?Hello again. Even though this thread has been marked as resolved, I noticed that the code I used from you, @shadez created an unexpected problem with the menus. All menus received the same name.
Finally, I found a solution and hopefully everything will be fine from now on. The main thing is that I’d like a default title to a specific post format, and it doesn’t matter how that happens, as long as I make it happen.
Here’s my code:
add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 2 ); function modify_post_title( $data , $postarr ) { if( has_post_format('status')) { if ($data['post_type'] == 'post') { $data['post_title'] = 'Status update | ' . date('j F Y'); } } return $data; }
Thanks again, though for all your help. I never thought this would work but it worked like a charm!
Forum: Hacks
In reply to: Create a default title based on post format status and or aside?Thanks again a bunch! I’ve tried it now and the best and simple solution to my problem was to take your code below, change a few things and set a title as the post is published. This way I also get a proper permalink as well.
add_filter('pre_post_title', 'set_default_newpost_data'); add_filter('pre_post_content', 'set_default_newpost_data'); function set_default_newpost_data($goofyvalue) { if ( empty($goofyvalue) ) { $time = date('F j Y'); $post_id = get_post_format(); return $post_id . '|' . $time; } return $goofyvalue; } function aside_post_publish( $goofyID ) { global $wpdb; if ( empty( $wpdb ) ) { return new WP_Error( 'invalid_post', __( 'Invalid post' ) ); } if( has_post_format('aside',$goofyID) && !wp_is_post_revision($goofyID) ) { $args = array(); $args['ID'] = $goofyID; $args['post_title' ] = 'Aside |' .date('F j Y'); remove_action('publish_post', 'aside_post_publish'); wp_update_post( $args ); add_action('publish_post', 'aside_post_publish', 10, 1 ); } } add_action('publish_post', 'aside_post_publish', 10, 1 ); function status_post_publish( $goofyID ) { global $wpdb; if ( empty( $wpdb ) ) { return new WP_Error( 'invalid_post', __( 'Invalid post' ) ); } if( has_post_format('status',$goofyID) && !wp_is_post_revision($goofyID) ) { $args = array(); $args['ID'] = $goofyID; $args['post_title' ] = 'Status update |' .date('F j Y'); remove_action('publish_post', 'status_post_publish'); wp_update_post( $args ); add_action('publish_post', 'status_post_publish', 10, 1 ); } } add_action('publish_post', 'status_post_publish', 10, 1 );
I can’t thank you enough for this!
Forum: Hacks
In reply to: Create a default title based on post format status and or aside?Thanks a bunch! I’ll try this and get back to you.
Forum: Hacks
In reply to: Need help with creating a plugin that import facebook status to wordpressActually, it doesn’t since I can’t afford and wont be able paying for that. I’d really like to know how yo create the plugin myself. Thanks anyway!
You’re welcome!
No, it does not. Tried that with one of the posts.
Nope, did not work for me. All it did was to prevent the checkboxes in the post meta box to be seen and checked. The post was published anyway. Did I do something wrong? Please, give me a more specific example or explanation to the code snippet.
Here’s the image of what happened: https://i.imgur.com/ANSkPR4.png
Thanks. I’ll try that and see if it works for me. I’ll get back later to tell you how it went.
Forum: Plugins
In reply to: [Jetpack - WP Security, Backup, Speed, & Growth] Re-publishI saw something about this here: https://vip.wordpress.com/documentation/customizing-publicize-sharing-behavior/#add-a-checkbox-to-send-new-post-updates-to-publicize
Tried it earlier today but it did not work. The check box showed up, but the published post did not get re-published.
Solved it!
Just had to change$content_width
in thefunctions.php
file to1260
and implement the new responsive video feature from jetpack that arrived the other day.Forum: Plugins
In reply to: [Redirection] Rediection import errorSame problem here. I have no idea what’s wrong.
I did that now and I get this message within my site’s stats:
Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in /storage/content/30/——/ameriksson.se/public_html/wp-includes/functions.php on line 2722
The hyphens in the url replaced an account numbers. Just ignore it.