• Hi there!

    I just created my first plugin.. using a template file.

    My template file:

    <div id=”social_media”>
    <?php add_action(‘template_redirect’, ‘ami_social_media’); ?>
     
    </div>

    My style.css file

    #social_media {
    margin:0 auto;
    position:relative;
    border:solid 1px #000;
    text-align:center;
    }

    functions.php

    function ami_social_media () {
    include(TEMPLATEPATH . ‘/social_media_plugin.php’);
    exit;
    }

    social_media_plugin.php

    <?php
    /*
    Plugin Name: Social Media
    Plugin URI: http://www.amitx.com
    Description: Plugin for displaying social media site icons
    Author: Web Administrator
    Version: 1.0
    Author URI: http://www.amitx.com
    */
    ?>

    <img src=”wp-content/themes/AMI/images/facebook_logo.png”>
    <img src=”wp-content/themes/AMI/images/icon_twitter.png”>

    The icons are pushed my layout div#wrap down and the icons are displaying in the top left of the screen.

    The icons are supposed to be displaying on the front_page.php where the social media div is.. this div is in a random part of the page. Should I be using the “template_redirect”?

    Your thoughts?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter thadfiebich

    (@thadfiebich)

    I just noticed, the plugin is displaying the icons on each page.

    It should have only displayed on the template page.

    Thread Starter thadfiebich

    (@thadfiebich)

    I am still having problems here. When I activate the plugin, it doesnt display where the div is on the page, instead it pushes my layout down and displays above.

    Is “Template_redirect” the right tag to use?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Plugin – using template_redirect – not displaying in right spot’ is closed to new replies.