First page of the Functions archive.

Remove Comment Form Website Section

Posted by The Doctor on Jan 17, 2012 with No Comments | Short Link
in Functions, Tips
as , , ,

From time to time an interesting Five-Minute-FixTM comes along that sparks a great reason to add another WordPress Tips post. The idea for this tip started with this comment at BuyNowShop.com:

… how to remove the website section when leaving a reply/comment …

The solution may be obvious to some and can be readily derived from the information found on the WordPress codex page for the `comment_form` function, but if you are new to WordPress and/or not familiar with writing a function to use with `add_filter`, here is a very simple and working snippet to use in your theme:

To see the tip click here.To hide the tip click here.
function wpfa_remove_comment_website_section(){
    $commenter = wp_get_current_commenter();
    $req = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
    $fields =  array(
        'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
        'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
        'url'    => '' /** removes website section */,
    );
    return $fields;
}
add_filter( 'comment_form_default_fields', 'wpfa_remove_comment_website_section' );

Ideally, this will be placed in the ‘functions.php’ file of your theme, but better yet this should be included in the Child-Theme you created of the theme you want to modify.

Do Not Display Comments HTML Tags

Posted by The Doctor on Aug 7, 2011 with 12 Comments | Short Link
in Functions
as , ,

A standard function found in many themes is the comment_form. This is a core function of WordPress that produces a standard comment form generally consisting of text fields for the name and email address and a textarea for the actual comment. You will also find there are some standard text outputs produced by this function as well, one of those is the allowed HTML tags that can be used in the form.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

If you do not want to display this text it is actually very easy to do. It can be done with a line of CSS or a minor edit to the theme in question. The following is based on using the comment_form function in its default state:

<?php comment_form(); ?>

To hide the message above with CSS, add one of the following to the end of your style.css file:

p.form-allowed-tags { display: none; }
p.form-allowed-tags { visibility: hidden; }

Using the display property “removes” the block of text whereas using the visibility property simply “hides” the text leaving the block being filled with nothing. Which method is best will be more due to aesthetics than anything else.

If you want to edit your theme files, look into the comments.php template file (again a standard default naming convention, your theme may vary), and find the default code noted above and change it to the following:

<?php comment_form( 'comment_notes_after=' ); ?>

Always remember, any edits you make to the theme may be over-written with the theme’s next update … always back-up your work.

the_widget() as a Shortcode Base

Posted by The Doctor on Sep 21, 2010 with No Comments | Short Link
in Functions
as , , ,

This post will further expand on the possible uses of the_widget() as the basis of the code you can use to create a shortcode for a WordPress sidebar widget.

An Implementation of wp_nav_menu

Posted by The Doctor on Sep 12, 2010 with 3 Comments | Short Link
Last modified by The Doctor on December 9, 2010
in Functions
as , ,

This article will show how to implement the wp_nav_menu() function using the wp_list_pages() function as a fallback.

Add the_shortlink()

Posted by The Doctor on Jul 22, 2010 with No Comments | Short Link
Last modified by The Doctor on September 9, 2010
in Functions
as ,

I believe there are many reasons for themes to use this function or add it to your WordPress web site. I will briefly discuss a couple of the ones that come to mind. Note, if you are using the default permalink structure this may not be for you as the_shortlink() creates a URL that looks [...]

Upgrade wp_list_categories() to wp_nav_menu()

Posted by The Doctor on Jul 20, 2010 with 6 Comments | Short Link
in Functions
as , , ,

In this third installment in the upgrade to wp_nav_menu() series of posts, I will be dealing with moving from wp_list_categories() to wp_nav_menu(). Let’s start with the same basic outline and list the default options for each function. We will start with wp_nav_menu() 1 first: We follow with wp_list_categories() 2, 3 which is often wrapped in [...]

Upgrade wp_list_pages() to wp_nav_menu()

Posted by The Doctor on Jul 16, 2010 with 1 Comment | Short Link
in Functions
as , , ,

A few options to address and with possibly a minor edit to the theme, you can upgrade wp_list_pages() easily to wp_nav_menu() in your theme.

Upgrade wp_page_menu() to wp_nav_menu()

Posted by The Doctor on Jul 12, 2010 with 11 Comments | Short Link
Last modified by The Doctor on July 25, 2010
in Functions
as , , ,

Upgrading from wp_page_menu() to wp_nav_menu() may be as easy as a simple find and replace operation.

Modified Post Function

Posted by The Doctor on Mar 18, 2010 with 1 Comment | Short Link
in Functions
as , , ,

A simple function to show who modified a post last and when in WordPress versions 3.0 and greater.

WordPress 3.0 Navigation Menu Styles

Posted by The Doctor on Mar 17, 2010 with No Comments | Short Link
Last modified by The Doctor on April 15, 2010
in Functions, Tips
as , , , , ,

A list of WordPress version 3.0 Navigation Menu default widget, and wp_nav_menu() function, generated CSS style elements.