Copyright messages for a particular set of pages

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.

Read More

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

Related posts

Leave a Reply

2 comments

  1. 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.

  2. 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!