Rectangle avatars

As far as I know the get_avatar() function only allows for square values. That doesn’t mean you couldn’t use styling to display a rectangular avatar. Essentially you would use styling to “shave off” 150px from the width. So, let’s assume that your theme file produces a 300 x 300 pixel avatar for the post author … Read more

Display all posts in current category

Try this: $cat = get_query_var(“cat’); $PozCat = get_category ($cat); $PozCat->id // give to us current cat id. Then use this hook in your query: <ul> <?php $cat = get_query_var(‘cat’); $PozCat = get_category ($cat); //$PozCat->id query_posts(‘posts_per_page=-1&cat=”.$PozCat->id); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/70634/<?php the_permalink();?>”><?php the_title(); ?></a></li> <?php endwhile; endif; … Read more

How to change featured content to a different tag in WordPress Twenty Fourteen?

The internal implementation details of that feature are of questionable sanity. If you take a look at said featured-content.php template you would see that it get posts from twentyfourteen_get_featured_posts() however the only thing that function has is twentyfourteen_get_featured_posts filter from quick look at which in peculiar fashion nothing is actually getting hooked because twentyfourteen_setup() declares … Read more

Add value to usermeta without removing previous values?

update_user_meta( int $user_id, string $meta_key, mixed $meta_value, mixed $prev_value=”” ) updates existing user meta based on user_id and meta key. If there are many fields with the same key, you can pass `prev_value’ to tell which field you want to update. add_user_meta( int $user_id, string $meta_key, mixed $meta_value, bool $unique = false ) adds meta … Read more

Execute a shortcode when clicking on a image

It’s certainly possible but you’re probably looking at doing an ajax request on the image click which in turn executes the short code and returns the output. This involves three distinct steps, binding the ajax request to an action, executing the ajax request and handling the response, and actually writing the script that will process … Read more

Automatically check the option “Enable stock management at product level” on product creation

To set default values of a new post, you can try this code : $postType = “product”; add_action(“save_post_” . $postType, function ($post_ID, \WP_Post $post, $update) { if (!$update) { // default values for new products update_post_meta($post->ID, “_manage_stock”, “yes”); update_post_meta($post->ID, “_stock”, 1); return; } // here, operations for updated products }, 10, 3);