How to safely edit functions.php

I don’t really think there is a safe way to make changes to your functions file, and for that matter any other template file. And I personally think that the back end editor are a big evil. It is unwise to make any changes to a live site, period. Any type of syntax or fatal … Read more

Changing the header image using WPML

You can use site_url() or get_site_url(). Depending on your install and setup, you could as well use network_site_url() – which is what I would prefer as it falls back to site_url() internally if it is no multisite setup. The site_url( $path, $scheme ); function also takes two arguments: The $path can be used to append … Read more

How to print the current post depth as update notification?

You should wrap your condition inside the function, rather than the function inside the condition (this will also prevent errors with code running too early as WordPress loads). function my_admin_notice() { global $wpdb, $post; $depth = $wpdb->get_var( $wpdb->prepare( “SELECT post_parent FROM $wpdb->posts WHERE ID = %d”, $post->ID ) ); if ( $depth == ‘0’ ) … Read more

contact form in template with jquery,validate and ajax

WordPress is running Jquery in noconflict mode. (WordPress Codex Reference) or read this brief article I posted some time ago. View it here. You need to replace: $(document).ready(function(){ With this: jQuery(document).ready(function($){ So all together, try this: jQuery(document).ready(function($){ $(“#contact_form”).validate({ rules: { name: “required”, email: { required: true, email: true }, message: “required” }, messages: { name: … Read more

Get the alphabetical sorted data with wpdb

It isn’t really WordPress-related indeed, but then again, OP doesn’t seem to know that, so here’s your answer :-). However, next time: this isn’t WordPress-related, please post PHP-questions in the corresponding SE. Sorting a PHP array can be achieved by using the sort function, which sorts an array alphabetically by its values. I’m assuming you … Read more

Call two different function.js depending on page

You can write conditionals in your functions.php file to conditionally load the javascript files. For example: function theme_scripts() { // If this is the home page, run this script if(is_home()) { wp_enqueue_script( ‘example-script’, get_stylesheet_directory_uri().’/path/to/file.js’); } // Otherwise, run this script else { wp_enqueue_script( ‘other-script’, get_stylesheet_directory_uri().’/path/to/file.js’); } } add_action( ‘wp_enqueue_scripts’, ‘theme_scripts’ ); Codex page for home … Read more

Replace admin header logo with an image

I think the path to the image is wrong, use get_stylesheet_directory_uri() to retrieve the style.css path. If this isn’t it let me know and I will take a closer look. I just dug out an example which worked for me in the past: function my_login_logo() { ?> <style type=”text/css”> body.login div#login h1 a { background-image: … Read more