Cropping images from top center using Jetpack Photon

We discussed about this issue in the WordPress.org support forums. Here is a code that should do the trick: /* * Let’s add support for Photon – that won’t be necessary once Jetpack 2.3.2 is out. * You’ll be able to use apply_filters( ‘jetpack_photon_url’… directly * See http://jetpack.me/2013/07/11/photon-and-themes/ */ if( function_exists( ‘jetpack_photon_url’ ) ) { … Read more

Custom url rewriting

[answer updated as wanted] It’s better to hook your function to generate_rewrite_rules so you won’t have fall into infinite loops and flushing rewrite rule on every request. So you can do this: function add_my_rules($wp_rewrite) { $new_rules = array( ‘^cityprofile/\?city=(Sydeny|Melbourne|Brisbane)$’ => $wp_rewrite->preg_index(1) // for 3 cities ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action(‘generate_rewrite_rules’, ‘add_my_rules’); and … Read more

Insert Message before content of after title

You need to use ‘the_content‘ filter function add_before_content($content) { return ‘Before content area ‘.$content; } add_filter(‘the_content’, add_before_content); It will still be inside the content div. If you want it outside the div you have to edit related template files i.e. single.php or templates/content-single.php. It all depends on which pages you want to apply it.

Undefined index: action plugin problem

The logic on line 225 is bad. if( isset($wp_logo_slider_images[‘update’]) == ‘Added’ || $wp_logo_slider_images[‘update’] == ‘Deleted’ || $wp_logo_slider_images[‘update’] == ‘Updated’) { isset($wp_logo_slider_images[‘update’]) is never going to equal ‘Added’ but that isn’t where the error comes in. PHP will try to use $wp_logo_slider_images[‘update’] twice on that line without checking that the value is set. What you need … Read more

WordPress as template engine

You might be misunderstanding exactly what WordPress is and how it operates. WordPress is a content management system, which in addition has it’s own API for working with the data held in the WordPress database as well as numerous other functions, actions and filters to help you achieve your desired result. WordPress also has it’s … Read more

Theme Custom Pages

You can use wordpress templates to load for a particular page. just create a template file with any name ( place template definition in file i.e commented code to declare a template) and select it as a template while adding a page. in this way file will be loaded automatically for page and you can … Read more

Create WordPress posts from JSON array using plugin in admin

Here I assume your json is an array of object where properties are named like wp_insert_post arguments: ‘post_title’, ‘post_content’ and so on. function process_ajax() { if ( ! isset($_POST[‘nonce’]) || ! wp_verify_nonce($_POST[‘nonce’], ‘mynonce’) ) die(‘error on checking nonce’); if ( ! isset($_POST[‘filepath’]) die(‘no file given’); if ( ! file_exists($_POST[‘filepath’]) ) die(‘invalid file given’); $posts = … Read more