internets, web dev, WordPress

Redirect category images to external site

Had a request to make the featured image of all custom posts in a specific category redirect to external pages, each link being different, and the client needed to be able to change the URLs on demand. Not sure if the approach I took was the best, but it seemed to work!

The custom taxonomies were created in ACF. The idea was to make a meta box in the custom post that would save the inputted text to the database, which inturn could be called later.

add_action( 'admin_menu', 'url_create' );
add_action( 'save_post', 'url_save', 10, 2 );
 
function url_create() {
    add_meta_box( 'url', 'URL', 'url', 'TAXONOMY', 'normal', 'high' );
}
 
function url( $object, $box ) { ?>

    <label for="sub_title">Redirect to:</label>
    <br />
    <input type="text" name="url" id="sub_title" cols="60" rows="4" tabindex="30" style="width: 97%;" value="<?php echo wp_specialchars( get_post_meta( $object->ID, 'URL', true ), 1 ); ?>" />
    <input type="hidden" name="url_nonce" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />

<?php }
 
function url_save( $post_id, $post ) {
    if ( !wp_verify_nonce( $_POST['url_nonce'], plugin_basename( __FILE__ ) ) )
    return $post_id;
    if ( !current_user_can( 'edit_post', $post_id ) )
    return $post_id;
 
    $meta_value = get_post_meta( $post_id, 'URL', true );
    $new_meta_value = stripslashes( $_POST['url'] );
 
    if ( $new_meta_value && '' == $meta_value )
        add_post_meta( $post_id, 'URL', $new_meta_value, true );
 
    elseif ( $new_meta_value != $meta_value )
        update_post_meta( $post_id, 'URL', $new_meta_value );
 
    elseif ( '' == $new_meta_value && $meta_value )
        delete_post_meta( $post_id, 'URL', $meta_value );
}

Then redirect placed in the header to target just the specific post type and redirect to the previously saved URL

<?php
$queried_post_type = get_query_var('post_type');
if ( is_single() && 'issues' ==  $queried_post_type ) {
  wp_redirect( get_post_meta($post->ID, 'URL', true) );
exit;
}
?>

Well it worked, which is great, but sure there was a better way!

Standard
Random

Apple watch coming soon

I like new Apple stuff, and I like watches.

Early next year the new watch from Apple will be available, and I am certainly looking forward to it.

There seems a good amount of choices and comes in two face sizes — 1.5 and 1.65 inches, but I do worry that you will have to have a new iPhone at launch, though the iPhone 5 should be ok.

Standard
internets, web dev, WordPress

Update WordPress to Version 4.0

Hi all, new version of WordPress (version 4.0) is out. There is some blurb below. Please remember to back up your database, and any core files you have altered when you update your site. Here is a quick checklist for you:

Backup your database
Backup all your files at your hosting
(Square Apple provides hosting with daily automated backups so have a think about switching over!)
Verify the backups have been successful
(If doing the manual upgrade remember to also deactivate your plugins first).

Version 4.0 of WordPress, named “Benny” in honor of jazz clarinetist and bandleader Benny Goodman, is available for download or update in your WordPress dashboard. While 4.0 is just another number for us after 3.9 and before 4.1, we feel we’ve put a little extra polish into it. This release brings you a smoother writing and management experience we think you’ll enjoy.

Looks pretty good so far, stable and

Standard
internets, Random

Spam comments for links

It is nice to get comments on the things you have written and shared, but like many sites, I still get an awful lot of people submitting comments for cheap links, without reading the blog or even being relevant to what has been written. Not to mention most don’t even make sense. I thought I would share a few with you anyway.

RED WING SHOES – Slendertone Bottom Toner shapes and tones your bottom. With splendid toning technology, the Slendertone product is convenient to wear beneath your clothes. Do you like to get a most efficient approach to have a bottom with better shape? Buy Slendertone”

Not too relevant to WordPress I guess.

wholesale nike shoes – Women seem to be more concerned about the shoe styles available for wear to work than the style of the fashions that remain in the closet. Women will usually invest in several pairs of shoes for work because some days the business needs might require s…”

Exactly, thats why I wrote about WordPress permissions on Plesk. Someone gets me, finally.

mulberry uk outlet – who actually is aware of what theyre talking about on the internet.”

Tell me about it…

Prada Mens Bags – And many reported health benefits like improved posture and less back pain, and less pain from running in general. All were generous with their praise and their ideas, often suggesting new and creative uses for FiveFingers.”

WTF?

mbt norge – Around of which with a superb Improve Crash Components discount can certainly make the elements and / or price extra inexpensive. They are not that hard to obtain internet additionally why don’t we find out where by many of us can certainly learn the…”

Yeah! lets….

Gucci Watches – naturally like your web site but you have to check the spelling on several of your posts. Several of them are rife with spelling issues and I find it very bothersome to tell the truth then again I will certainly come back again.”

Well thanks, I guess, let me just link to your site for you….

viagra – MILF cam websites verify that anyone can make money via the internet,”

Cool, I’ll let my mum know about that.

coach factory outlet online – Can I simply say what a relief to find someone who actually knows what theyre speaking about on the internet. You definitely know how to bring a problem to gentle and make it important. More people have to learn this and understand this aspect of the s…”

Well thank you sir, I often bring my problems to gentle. It’s easier that way.

アシックス スニーカー – My spouse and i transferred our SSH factor to Eating habits Coda while using the clipboard. I utilized PasteBot from Tapbots to seize the true secret out of your clip-board on my Mac pc along with the item inside the clip-board in the apple ipad.”

Shit, couple got mad tech skills….

ray ban sunglasses – Your house is valueble for me. Thanks!?”

Cool, make me an offer then!

oakley sunglasses – An interesting dialogue is worth comment. I believe that you must write extra on this subject, it might not be a taboo subject but typically people are not enough to speak on such topics. To the next. Cheers”

Exactly, too many people have their oakley sunglasses on when writing about the WordPress pinglist…

coach factory outlet online – I抦 impressed, I have to say. Actually rarely do I encounter a weblog that抯 each educative and entertaining, and let me let you know, you will have hit the nail on the head. Your concept is outstanding; the issue is one thing that not sufficient people…”

Why stop? Tell me more.

coach outlet – I was very happy to find this web-site.I needed to thanks in your time for this wonderful learn!! I undoubtedly having fun with each little little bit of it and I have you bookmarked to check out new stuff you weblog post.”

Thanks coach outlet come again…

Maybe I’ll approve any comments on this post, maybe not….

Standard