Misleading information in the Codex, how do they get away with it? [closed]

First of all, wp_list_cats() was already depreciated in version 2.1, which a couple of millenia ago. You should not be using functions which is marked depreciated. In all probability, the info regarding the specific function is almost always wrong as it is long time outdated. You should really develop with debug set to true. If … Read more

Use template tags in code snippets wordpress

Just tested this and it worked on my end. The shortcode itself would be [titlelink] function titlelink_ssc($content = null) { ob_start(); echo ‘<a href=”‘.get_permalink().'” title=”‘.get_the_title().'”>’.get_the_title().'</a>’; $titlelink_ssc = ob_get_clean(); return $titlelink_ssc; } add_shortcode(“titlelink”, “titlelink_ssc”);

How to modify template tags function?

There is no get_user_meta filter. Despite WP often having filters same as function name, it isn’t the rule exactly. There is however deeper filter in more generic get_metadata() function: $check = apply_filters( “get_{$meta_type}_metadata”, null, $object_id, $meta_key, $single ); if ( null !== $check ) { if ( $single && is_array( $check ) ) return $check[0]; … Read more

How do I str_replace with template tag?

This function will return the featured image without the class attribute: function wpse239577_post_thumbnail( $image_size=”full” ) { $image_id = get_post_thumbnail_id(); $image = wp_get_attachment_image_src( $image_id, $image_size ); if ( ! $image ) { return false; } return ‘<img src=”‘ . esc_url( $image[0] ) . ‘” alt=”” />’; } Usage: echo wpse239577_post_thumbnail(); The $size parameter is a WordPress … Read more

Sort list of page templates a-z?

You can use ksort() function to sort the array of $templates = get_page_templates();. So the full code will be- <?php $templates = get_page_templates(); // Sort based on key ksort($templates); foreach ( $templates as $template_name => $template_filename ) { echo “$template_name ($template_filename)<br />”; } ?> Also see asort() if you need.