What is the difference between get_page_link and get_permalink functions?

When i explored the WordPress core for this answer i found that get_permalink() function internally calls get_page_link() function for getting permalink of page and it calls get_post_permalink() function to get permalink of post. Therefore either you use get_permalink() function or get_page_link() function, you will get same result. The difference between these two is get_page_link() function … Read more

Redeclare a function in a child theme

Redeclaring a function in a child theme only works when the parent themes’ function is wrapped in a if( !function_exists( ‘function_name’ )): condition. Then you can simply just copy the complete function to the child theme and do whatever modifications you need to do. If the parent themes’ functions aren’t wrapped in that if conditional … Read more

What is the correct MIME type for PSD (Photoshop)

This is what I use to allow PSD upload: add_filter(‘upload_mimes’, ‘custom_upload_mimes’); function custom_upload_mimes ( $existing_mimes = array() ) { $existing_mimes[‘psd’] = ‘image/vnd.adobe.photoshop’; return $existing_mimes; }

Add custom template page programmatically

The article linked is on the right track, but i’ll make it more simple for you.. 😉 add_filter( ‘page_template’, ‘catch_plugin_template’ ); function catch_plugin_template( $template ) { if( ‘tp-file.php’ == basename( $template ) ) $template = WP_PLUGIN_DIR . ‘/yourpluginname/tp-file.php’; return $template; } The filter basically looks to see if your special page template is set for … Read more

Get list of years when posts have been published

Your question is pretty old, but I just wanted to add a real solution to your question. Here’s a function that will return an array of years you have posts published in. You can put this function in functions.php or in a plugin or whatever you want. function get_posts_years_array() { global $wpdb; $result = array(); … Read more

What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])

Your website has been hacked. This is malicious code that gets triggered from the outside, loading more malicious content from ‘www.dolsh.cc’ domain. If the content comes back after you remove it, then you have hacked files somewhere else that will automatically rewrite functions.php any time page is loaded. You need to find and clean up … Read more

Why does WordPress have private functions?

It is quite normal practice for code to not be a part of public API. But much of WP code is ancient and procedural. There are no technical ways to make a private function. These are semantically private, that is WP doesn’t want you to use them, but it cannot actually forbid you to. There … Read more

Is it possible to rename a post format?

I think this is the only way for now. Put this in your functions.php in your theme folder or create a simple plugin: function rename_post_formats( $safe_text ) { if ( $safe_text == ‘Aside’ ) return ‘Quick’; return $safe_text; } add_filter( ‘esc_html’, ‘rename_post_formats’ ); //rename Aside in posts list table function live_rename_formats() { global $current_screen; if … Read more