• I have the code I need to create a new blog template. Where do I put that code?? I know it goes in my Editor, but under which section? I tried putting it under the code already in the blog.php file, but it doesn’t work. Here is the code in case it’s helpful in directing me to the correct place.

    Code for new template:
    <?php
    /*
    Template Name: WPBeginner Blogger
    */
    global $wpdb;
    $old_url = $_GET[‘q’];
    if ($old_url != “”) {

    // Fix for blogger blogs with .de and other tlds in their URLs
    $tld_fix = preg_replace(“/blogspot.[a-zA-Z0-9]+/”, “blogspot.com”, $old_url);
    $permalink = explode(“blogspot.com”, $tld_fix);
    $q = “SELECT guid FROM $wpdb->posts LEFT JOIN $wpdb->postmeta “.
    “ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “.
    “$wpdb->postmeta.meta_key=’blogger_permalink’ AND “.
    “$wpdb->postmeta.meta_value=’$permalink[1]'”;
    $new_url = $wpdb->get_var($q)? $wpdb->get_var($q) : “/”;
    header (“HTTP/1.1 301 Moved Permanently”);
    header(“Location: $new_url”);
    }
    ?>

    I have Googled this to death & none of the directions are specific enough in placing the code.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create New Blog Template (have code already)’ is closed to new replies.