Get attachments by user

Use a custom query for this. $user_id = 1; $the_query = new WP_Query( array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘author’ => $user_id) ); if ( $the_query->have_posts() ) while ( $the_query->have_posts() ) : $the_query->the_post(); the_title(); endwhile; This will show all the attachment titles for user with user id 1. You can use get_the_ID() in the … Read more

Custom php page in WordPress theme?

Move the template files out of the subdirectory, and put them in the Theme’s root directory. Then, if you simply want to include the contents of those template files in other template files, simply call get_template_part( ‘test-page-name.php’ );. If you insist on keeping these files in a subdirectory, you’ll need to include them via locate_template().

file_get_contents Not allowed in Themes?

Line 49: $data = file_get_contents ( ‘http://example.com’); Don’t use file_get_contents to download web page. WordPress has HTTP API for such needs. In your case, I would suggest you to use wp_remote_get( ‘http://example.com’ ); function instead of file_get_contents. Further reading: WordPress HTTP API wp_remote_get function.

Add social icons in a theme through custom admin menu

I did something similar on my site a while back. I’m sure you can tweak it to fit your needs. Under each article I have an author box with social media icons that link to their accounts. In content-single.php <?php if ( get_the_author_meta(‘twitter’) ) : ?> <a href=”http://www.twitter.com/<?php the_author_meta(‘twitter’); ?>” title=”Twitter”><img src=”<?php bloginfo( ‘url’ ) … Read more

WooCommerce: VAT on grouped products

code update: add_action( ‘woocommerce_grouped_product_list_before_price’, ‘woocommerce_grouped_product_tax_on_single’, 10, 1, $child_product, $mode ); function woocommerce_grouped_product_tax_on_single( $child_product, $mode = null ) { //uncomment next line and choose one of the output options from »switch case “{OPTION}”« //$mode=”tax-name-rate-amount”; $_taxobj = new WC_Tax(); $obj = $_taxobj->get_shop_base_rate($child_product->get_tax_class()); $i_or_e = get_option(‘woocommerce_prices_include_tax’) == ‘no’ ? ‘excl.’ : ‘incl.’; ?> <td class=”grp_tax”> <?php foreach ( … Read more