Articles of codex

How to use Internationalized human_time_diff() function in Chinese?

Looking at https://codex.wordpress.org/Function_Reference/human_time_diff I’m using an English version of WordPress. In my theme template, I would like to define custom text of min, hour, day, week, month, year in Chinese using human_time_diff() when looping through posts. According to the instruction in the Codex documentation: <?php printf( _x( ‘%s ago’, ‘%s = human-readable time difference’, ‘your-text-domain’ […]

What are these undocumented arguments for register_taxonomy?

The WordPress codex has an example of the register_taxonomy() function at http://codex.wordpress.org/Taxonomies that shows arguments that are not documented in http://codex.wordpress.org/Function_Reference/register_taxonomy. In particular args[‘sort’] and args[‘args’][order_by]. What’s the story with these?

Do I need to include a textdomain if my theme doesn't support translation?

According to the codex Themes are required to use theme-slug (or a reasonable facsimile) as textdomain for translation Does this mean that my theme needs to include a textdomain even if my theme doesn’t support translation? … and also is there any harm in including a textdomain in style.css if there are no translation options.

post_class not working with css

through the codex I read about how to use the post_class() function to create a css hook for styling the content. Here is the code I have, PHP: <li class=”<?php post_class();?>”> <?php the_title(); ?> </li> <p class=”<?php post_class(); ?>”> <?php the_content(); ?> </p> However, the following CSS does not work, the styling does not change: […]

Programatically added attribute, set to 'show on product page' automatically. Woocommerce

Ive written a script to import products to a new install of Woocommerce. The products have attributes set up in the admin. This bit of code adds the attributes on import. update_post_meta($product_id, ‘common_name’, $product[‘common_name’]); wp_set_object_terms($product_id, $product[‘flowering_period’], ‘pa_flowering’); wp_set_object_terms($product_id, $product[‘native_plant’], ‘pa_native’); However when I look at the product attribute in admin, the tick box for ‘show […]

get_month_link uses what wordpress template?

I tried using archive.php and category.php but always index.php is used of my template. How can I customize what template file is used?

Changing next and previous post link text

So I’ve been staring at the CodeX for about 10 minutes and can still not figure how to do this next and previous on a the post page. So I’ve added <?php next_post_link(); ?> and <?php next_previous_link(); ?> to my page and works perfectly but I want it to say Next Post and Previous Post […]

What is the significance of _e(“Some String”, 'String')?

I have seen this in lots of wordpress themes and using it for a while but don’t know what is the significance of it. It seems it does the same work as echo something out. Look for it in codex but failed to find anything about it. May be i have looked in wrong place. […]

REQUIRED: get_bloginfo('template_url') was found in the file search.php. Use get_template_directory_uri() instead

Theme Check error → REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead. Line 21: <img src='<?php echo get_bloginfo(‘template_url’) ?>/img/no_results_found.png’/> I acted and made the changes, but the image is now not coming in live webpage → <img src='<?php echo get_template_directory_uri() ?>/img/no_results_found.png’/> Is there any mistake in the above?

Breadcrumbs – get the author?

I have my own function called breadcrumbs(). In it I call is_author() to determine whether I am on an author page. If true I would like to know which author’s page I am on. I tried the_author(), but nothing came up. I looked through the WP codex also. Can someone please help?