Assign a picture URL to a page via PHP

You can use the add_post_meta function: add_post_meta( get_the_ID(), ‘my_custom_image_url’, ‘http://domain.com/image.jpg’, true ); The code above assumes that a) you will have only one image per page; and b) you are in a loop so get_the_ID will return a valid ID of the page you want to attach the meta-data to. Documentation here.

How to make thumbnail image fit into a div where image dimentions are completely different?

It may be that some of your images were uploaded before you created the custom image size function. If that’s the case, a plugin like Force Regenerate Thumbnails will solve your problem. Alternatively, for more versatility you could use the images as backgrounds, like so: <div style=”background-image: url(<?php the_post_thumbnail_url(); ?>)” id=”post-thumbnail”></div> and set the background … Read more

Replace comment avatars and links at the same time

Maybe I was burned out from work before, but this morning I took another go at the same code and managed to get it running properly. if ( ! function_exists( ‘comment_imgs’ ) ) { add_filter( ‘get_comment_author_url’, ‘comment_imgs’ ); function comment_imgs( $avatar, $id_or_email, $size, $default, $alt ) { global $comment; // We do not get the … Read more

Rewrite sub folder dynamically with country code in WordPress using PHP

I think the most difficult part is to remove the subfolder part from the url with WordPress website on both places. What if you change subfolder name to international and change rewrite rules to have ISO codes before the urls? So you would have: http://example.com http://example.com/international/uk http://example.com/international/us To add the iso codes you try to … Read more