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 have created some pages (not post) in wordpress related to my college notes.

I would like to display a copyright message of the college on this pages, but I don't want do this manually every time.

So is there any plug-in or tweak available to achieve this?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You could add a custom field to the pages you want to show the copyright on and have your page.php (or header.php or index.php or whatever) look for it.

Example: Set a custom field of "show_copyright" to "1" in the page editor.

In your page.php, right above <?php endwhile; endif; ?>, add this:

<?php
if ( get_post_meta($post->ID, 'show_copyright', true) ) {
    ?>
    <div class='copy'>
        This is your copyright notice.
    </div>
    <?php
}
?>

Now, that said, there's another way you could do it. Make a copy of your page.php, index,php, whatever, to a new name like "copyright.php". Add your copyright message into that, and at the very top of the file, add this:

<?php
// Template Name: Copyright Notice
?>

Then, when editing your page, change the Page Template on the right to "Copyright Notice". The trouble with this second method, though, is if you decide to change something in your website, you'll need to edit both your page.php file (or index, blah blah) as well as your copyright.php.

share|improve this answer
    
If I add your code to the header.php, my page breaks, so I tried adding it to Page Template (page.php) and it does not break but the only problem is it goes extremely below, somewhat 10-12 lines. –  Searock Mar 13 '11 at 10:20
    
Sorry for bothering you, the copyright message would go 10-12 lines below as there was a css class for copyright. So I changed it to copy and it works fine. And can you edit your answer to include page.php instead of header.php and instead of pasting your code at the bottom, can you replace it with pasting it above <?php endwhile; endif; ?> so than I can mark your post as an answer. Thanks a lot for your quick response. –  Searock Mar 13 '11 at 10:31
    
Made the edits... it really depends on where you want the copyright to show up, though, as to where the code gets added. :) –  Rob Williams Mar 13 '11 at 12:13
add comment

Two more methods both without editing any theme files (well, almost).

Method One - the_content filter

add_filter('the_content','my_copy_right_notice');
function my_copy_right_notice($content){
    if (is_page){
        global $post;
        if (get_post_meta($post->ID, 'show_copyright', true)){
            $copyright ='<div class="copy">
                        This is your copyright notice.
                    </div>';
            $content = $content . $copyright
        }
    }
    return $content;
}

similar to before, after you add this to your functions.php on any page you would like to display the copyrights then just set a custom field of "show_copyright" to "1" in the page editor.

Done!

Method Two - custom shortcode

add_shortcode('MY_COPY','my_copy_right_notice_shortcode');
function my_copy_right_notice_shortcode($content){
    $copyright ='<div class="copy">
                    This is your copyright notice.
                </div>';
    return $copyright;
}

after adding this code to your functions.php file on any page or post you want the copyright notice to show just add [MY_COPY] inside the editor and Done!

share|improve this answer
    
++ on the custom shortcode. Absolutely the best and most flexible way to do it. –  ZaMoose Mar 13 '11 at 18:15
    
Thanks a lot for the advice. –  Searock Mar 14 '11 at 4:20
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.