Forcing oembeds to top of post

you can create custom post meta which contain youtube url and then $yt=get_post_meta($post->ID,’youtube_url’,true); if( ” != $yt) echo $GLOBALS[‘wp_embed’]->autoembed( $yt ); Updated: If i’m getting correctly then your content contain youtube url any where in it and you want to show them at top regardless there position in content. jut paste this code in functions.php … Read more

Is it possible to add a first and latest posts link?

What you need are $GLOBALS[‘wp_query’]->max_num_pages and get_pagenum_link(). Then you just have to compare get_query_var( ‘paged’ ) with max_num_pages and create a link if they are not equal: /** * Link to last page of a paged archive. * * @param string $text Link text * @return string Nothing if we are on the last page, … Read more

Setting pagination for images attached to a post

You could use paginate_links() to paginate the total gallery. This highly depends on your permalink settings. The best would be to check other answers on that topic here on WPSE. Next/Prev post links for attachments. Than there’s also the task to navigate on single attachment display. Default API function/template tag There’s the adjacent_post_link() function that … Read more

How to force update all posts after import

There are 2 ways that you could do this. The first and more difficult is to write a program, the other is to do a bulk update. Why do difficult when easy way will work equally well? and especially as this is a once-off requirement The easy way: In the admin dashboard, select the view … Read more

$post->ID displays wrong ID

On that page $post->ID returns the ID of first blog post for given page. That is how it works. $post is set to the first post in the Loop. On single posts and pages that is the same as the post or page. On archive pages it is the first post in the result set. … Read more

Unattaching images from a post

This can be done using an Ajax call that will query the database and set the parent as “zero”. First, create a meta box, enqueue the Javascript that calls the unattach function and register this WP_Ajax function. <?php /* Plugin Name: Unattach Meta Box Version: 0.3 Author: brasofilo Plugin URI: http://wordpress.stackexchange.com/q/54822 */ add_action( ‘add_meta_boxes’, ‘wpse_54822_add_custom_box’ … Read more

Add default content to post (for specific category)

default_content runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you’d want the save_post hook, probably. You want to check the $_REQUEST global. add_filter( ‘default_content’, ‘my_editor_content’ ); function my_editor_content( $content ) { global $_REQUEST; if (isset($_REQUEST[‘post_category’]) && in_array($some_category_id,$_REQUEST[‘post_category’])) { $content = “My html … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)