Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i would like to add an image above the post title... in the old days i would change that directly in wordpress code but thats not very affective.. you know, upgrades and such.

is ther a way using add_meta_box or some othere way to add a box directly above the post title?

tried this Priority of Meta Box for Custom Post Type

BUt that didnt work.. help Please :)

share|improve this question
    
if you are concerned with upgrades, and the theme is suitable for it, create a child theme and change the code there. –  Michael Sep 4 '11 at 21:59
    
I think he means in the admin area? –  chrisguitarguy Sep 4 '11 at 22:14
add comment

2 Answers

up vote 3 down vote accepted

The only real chance you got is to hook into admin_notices, which is above the post-new.php page title & icon:

function  wpse27700_above_title_content()
{
    ?>
    <style>
    /* 
    You might need to attach some styles here,
    to not get into the admin notices styles 
    */
    </style>

    <h1>TEST</h1>
    <p>This is a test message</p>
    <?php
}

// This is needed to only hook on the post new & edit screens.
function wpse27700_admin_head()
{
    add_action( 'admin_notices', 'wpse27700_above_title_content', 9999 );
}
add_action( 'admin_head-post-new.php', 'wpse27700_admin_head' );
add_action( 'admin_head-post.php', 'wpse27700_admin_head' );
share|improve this answer
    
i See there is now use of add_meta_box... But, This works beautifuly!! thanks a lot @kaiser –  Sagive SEO Sep 6 '11 at 12:07
add comment

My answer is assuming you mean in the admin area on the post editing screen.

Unfortunately there are no hooks to add things above the title.

I did track down a (very hacky?) way to do this, however, by looking at the code for Premise (a landing page plugin by Copyblogger Media).

Hook into something like dbx_post_sidebar, which is below all the post editing stuff and metaboxes. Echo out your image with a style attribute containing display:none;

<?php
add_action( 'dbx_post_sidebar', 'wpse27700_add_image' );
function wpse27700_add_image() 
{
    echo '<img id="wpse27700-image" src="http://placebear.com/500/100" alt="wpse27700 bear" style="display:none;" />';
}

Then using jQuery you can remove the image and place it above the title. I just hooked into admin_head to do this, but you can also enqueue a separate js file or whatever.

<?php
add_action( 'admin_head', 'wpse27700_admin_head' );
function wpse27700_admin_head()
{
    ?>
    <script type="text/javascript">
        jQuery(document).ready(function(){
            var wpse27700 = jQuery('#wpse27700-image');
            wpse27700.remove();
            jQuery('#titlediv #titlewrap').before(wpse27700.show());
        });
    </script>
    <?php   
}

Not the most direct solution, but it works. As a plugin: https://gist.github.com/1193612

share|improve this answer
1  
I bet your fingers hurt a little when typing that. This same user posted on a blog post of mine asking the same question. It's unfortunate that there is no hook above the title to add something. I, too, made the suggestion of using JS to place the element. I felt really dirty about it though. –  tollmanz Sep 4 '11 at 22:38
    
I wonder if he was looking for a different answer this time around? –  chrisguitarguy Sep 4 '11 at 22:50
    
You did @tollmanz ? sorry, i think i search for the "notify my on comments" button and didnd find an option (sorry if i am mistaken:) ) –  Sagive SEO Sep 6 '11 at 11:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.