WordPress FAQ

WordPress FAQ

Q. What are the types of hooks in WordPress
a. There are two types of hooks 1) Action hooks 2) Filter hooks

Q. What is custom field in wordpress?
a. Custom field is a meta-data that allows you to store arbitrary information to the wordpress post.

Q. What is the prefix of wordpress tables by default ?
a. By default, wp_ is the prefix for wordpress.

Q. What is WordPress Loop
a. To display post WordPress use PHP code, this code is known as loop.

Q. Why widget does not show up in the sidebar?
a. While using widget you have to ensure whether your theme supports the widget and if it does then it must show the sidebar. If in any case if it happens that you don’t see the sidebar then it might be missing the “function.php” file or file similar to that. This can also happen if you have forgot to save the changes in the widget or refreshing the older display of the page.

Q. What are meta-tags?
a. Meta-tags are keywords and description used to display website or page information.

Q. What are the reasons why one should not hack WordPress core file?
a. The best reason not to hack the core files is that whatever you might be doing has to be reworked as a patch.

Q. How to hide the top admin bar at the frontend in WordPress?
a. Add below line in function.php
add_filter('show_admin_bar', '__return_false');

Q. How to hide Directory Browsing in WordPress from server?
a. Add following code in htaccess file
Options -Indexes

Q. How to display custom field in wordpress?
a. echo get_post_meta($post->ID, 'keyName', true);

Create change password Page

Create change password Page

to create a change password page for user in WordPress

just save the code into your current theme directory

Create new page in wp-admin/page name it as change

select template “change password”

publish it. thats all its done .

 

code 

 

 

Change WordPress default email

Change WordPress default email

Every time someone submitted a comment on your blog, signed up as a user or did anything that required WordPress to generate and send an e-mail, by default the “From Name” in that message appeared as “WordPress” and “From” address was “wordpress@your-domain.com”.
if you want to change this, just copy the below code to your functions.php

 

WordPress Cheat sheet

WordPress Cheat sheet

This WordPress Cheat Sheet should be enough to get you started developing or tweaking WordPress themes.

Basic Template Files
style.css Style sheet file
index.php Home Page file
single.php Single post page file
archive.php Archive or Category file
searchform.php Search form file
search.php Search content file
404.php Error page file
comments.php Comments template file
footer.php Footer content file
header.php Header content file
sidebar.php Sidebar content file
page.php Single page file
PHP Snippets for Header
bloginfo(‘name’); Title of the site
wp_title(); Title of the specific post or page
get_stylesheet_directory_uri(); The style.css file’s location
bloginfo(‘pingback_url’); Pingback URL for this site
bloginfo(‘template_url’); Location for the site’s theme files
bloginfo(‘version’); WordPress version for the site
bloginfo(‘atom_url’); Atom URL for the site
bloginfo(‘rss2_url’); RSS2 URL for the site
get_site_url(); Exact URL for the site
bloginfo(‘name’); Name of the site
bloginfo(‘html_type’); HTML version of the site
bloginfo(‘charset’); Charset parameter of the site
PHP Snippets for Templates
the_content(); Content of the posts
if(have_posts()): Check if there are posts
while(have_posts()): the_post(); Shows posts if posts are available
endwhile; Closes the ‘while’ PHP function
endif; Closes the ‘if’ PHP function
get_header(); Header.php file’s content
get_sidebar(); Sidebar.php file’s content
get_footer(); Footer.php file’s content
the_time(‘m-d-y’); The date in ’08-18-07′ format
comments_popup_link(); Link for the comments on the post
the_title()’; Title of a specific post or page
the_permalink(); URL of a specific post or page
the_category(); Categor of a specific post or page
the_author(); Author of a specific post or page
the_ID(); ID of a specific post or page
edit_post_link(); Link to edit a specific post or page
get_links_list(); Links from the blogroll
comments_template(); Comment PHP file’s content
wp_list_pages(); List of pages of the site
wp_list_cats(); List of categories for the site
next_post_link(‘%link’); URL to the next post
previoust_post_link(‘%link’); URL to the previoust post
get_calendar()’ The built-in calendar
wp_get_archives(); List of archives for the site
posts_nav_link(); Next and previous post links
bloginfo(‘description’); Site’s description
Navigation menu
Category Based Navigation
<ul id=”menu”>
<li <?php if(is_home()) { ?> class=”current-cat” <?php } ?> >
<a href=”<php bloginfo(‘home’); ?>”>Home</a></li>
<?php wp_list_categories(‘title_li=&orderby=id’); ?>
</ul>
Pages based Navigation
<ul id=”menu”>
<li <?php if(is_home()) { ?> class=”current_page_item” <?php } >>>
<a href=”<php bloginfo(‘home’); ?>”>Home</a></li>
<?php wp_list_pages(‘sort_column=menu_order&depth=1&title_li=’); ?>
</ul>
Extra stuff
/%postname%/ Custom permalinks
include(TEMPATEPATH . ‘/x’); Include any file
the_search_query(); Value for search form
_e(‘Message’); Prints out message
wp_register(); Displays the register link
wp_loginout(); Displas the login/logout link
<!–next page–> Divides the content into pages
<!–more–> Cuts off the content and adds a read more link
wp_meta(); Meta for administrators
timer_stop(1); Time to load the page
echo get_num_queries(); Queries to load the page
The Loop
<php if(have_posts()): ?>
<php while(have_posts()): the_post(); ?>
// Post content here (Custom HTML & PHP code)
<php else; ?>
<php endif; ?>
The Loop

 

Extend User Contact Fieds in WordPress

Extend User Contact Fieds in WordPress

We can add lots of contact information, depending upon your needs. To extend user contact info, open the files and add in this code


 

This is only a basic example and you can make it more complicated depending on your creative needs