How to add author details in the post sidebar?

global $authordata; This variable contains the current post’s author data. From an author data widget I have written: global $authordata; if ( ( is_singular() or is_author() ) and is_object( $authordata ) and isset ( $authordata->ID ) ) { return $authordata->ID; } To get the link to the author archive: get_author_posts_url( $authordata->ID ); Update Here is … Read more

how to upload image using wp_handle_upload

here’s my example of how to upload multiple images: add_action( ‘add_meta_boxes’, ‘my_test_metabox’ ); function my_test_metabox() { add_meta_box( ‘my_test_metabox’, ‘File upload’, ‘my_test_metabox_out’, ‘post’ ); } add_action(‘post_edit_form_tag’, ‘update_edit_form’ ); function update_edit_form() { echo ‘ enctype=”multipart/form-data”‘; } function my_test_metabox_out( $post ) { $files = get_post_meta( $post->ID, ‘my_files’, true ); if( ! empty( $files ) ) { echo ‘Files … Read more

How do I reorder (pop and push) items from WP_Query?

You could use the Metadata API to retrieve the rw_advertising_position metadata for each post, seperate the ads from the content, and then re-insert the ads at the proper locations: /** * Extracts from an array posts with positional metadata and re-inserts them at the proper * indices. See https://wordpress.stackexchange.com/questions/210493 **/ function wpse_210493_apply_advertising_position( &$posts, $return = … Read more

get product attributes for current product and store it in a variable

get_terms() Retrieves the terms in a given taxonomy or list of taxonomies. What you need is get_the_terms() Retrieves the terms of the taxonomy that are attached to the post. So you can simply replace $brand_terms = get_terms( ‘pa_liquor-brands’ ); with $brand_terms = get_the_terms( $post, ‘pa_liquor-brands’ ); And that should to the trick. You can read … Read more

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