Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Types of post type

 Post (Post Type: 'post')


 Page (Post Type: 'page')
 Attachment (Post Type: 'attachment')
 Revision (Post Type: 'revision')
 Navigation Menu (Post Type: 'nav_menu_item')
 Custom CSS (Post Type: 'custom_css')
 Changesets (Post Type: 'customize_changeset')

What is custom post type

Custom post types are new post types you can create. A custom post type can be added to WordPress
via the register_post_type()function

add_action( 'init', 'create_post_type' );

function create_post_type() {

register_post_type( 'acme_product',

array(

'labels' => array(

'name' => __( 'Products' ),

'singular_name' => __( 'Product' )

),

'public' => true,

'has_archive' => true,

);

7) What are the types of hooks in WordPress and mention their functions?

There are two types of hooks 1) Action hooks 2) Filter hooks

Hooks allow user to create WordPress theme or plugin with shortcode without changing the
original files.

Action hooks allow you to insert an additional code from an outside resource, whereas,
Filter hooks will only allow you to add a content or text at the end of the post.

8) What do you mean by custom field in wordpress?


Custom field is a meta-data that allows you to store arbitrary information to the wordpress
post. Through custom field extra information can be added to the post.

10) What are the rules that you have to follow for wordpress plugin development?
 Create a unique name
 Create the plugin’s folder
 Create a sub-folder for PHP files,  translations and assets
 Create the main plug-in file and fill in header information
 Create activation and de-activation functions
 Create an uninstall script
 Create a readme.txt file
 To detect paths to plugin file use proper constants and functions

16) How you can disable the WordPress comment?

If you go on dashboard under options-discussion there is a comment “ Allow people to post


comment” try unchecking the comment.

36) What are meta-tags?

Meta-tags are keywords and description used to display website or page information.

Posts vs. Pages (Key Differences)

The differences we list below definitely have exceptions. You can use plugins or code
snippets to extend the functionality of both content types. Below is the list of key
differences by default.
 Posts are timely vs. Pages are timeless.

 Posts are social vs. Pages are NOT.

 Posts can be categorized vs. Pages are hierarchical.

 Posts are included in RSS feed vs. Pages are not.

 Pages have custom template feature vs. Posts do not.

Pages

Pages are meant to be static “one-off” type content such as your about page, privacy
policy, legal disclaimers, etc. While the WordPress database stores the published date
of the page, pages are timeless entities. For example, your about page is not suppose
to expire.

Posts

If you are using WordPress as a blog, then you will end up using posts for majority of
your site’s content. Posts are content entries listed in reverse chronological order on
your blog’s home page. Due to their reverse chronological order, your posts are meant
to be timely. Older posts are archived based on month and year. 

Two type of post

Categories are meant for broad grouping of your posts.

Tags are meant to describe specific details of your posts.

Page template

WordPress by default comes with a feature that allows you create custom page templates using
your theme. This allows developers to customize the look of each page when necessary. 

Taxonomy

In WordPress, a "taxonomy" is a grouping mechanism for some posts (or links or custom post
types). The names for the different groupings in a taxonomy are called terms.

Question: How to create a folder if it doesn't already exist in


Wordpress?

$pathname='path/to/directory';
if (!file_exists($pathname)) {
mkdir($pathname, 0777, true);
}

Question: How to get the current page name in WordPress?


You can get the page name from below of two?

$slug = basename(get_permalink());
OR

$pagename = get_query_var('pagename');

Question: How do I ge the version of wordpress?

echo bloginfo('version');

Question: How to turn off the Notice/Warning from my wordpress


website?
Open the wp-config.php file and WP_DEBUG set the false.

define('WP_DEBUG', false );

Question: How to get wordpress post featured image URL?

if (has_post_thumbnail( $post->ID ) ){
$image = wp_get_attachment_image_src( get_post_thumbnail_id(
$post->ID ), 'single-post-thumbnail' );
echo $image[0];//image url
}

Question: How to get last inserted row id from wordpress


database?

global $wpdb;
$lastId = $wpdb->insert_id; //This is last insert id

Question: How to Remove P and Br tags in WordPress posts?


Open functions.php in your current active theme.
Add following lines
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

Question: How do I get current taxonomy "term id" on


wordpress?

$obj = get_queried_object();
echo $obj->term_id;

How to protect your website from DDos Attack?


Add following code in your .htaccess file.
<files xmlrpc.php>
      order allow,deny
      deny from all
    </files>

Actions Functions:
has_action()
add_action()
do_action()
do_action_ref_array()
did_action()
remove_action()
remove_all_actions()
Filter Functions:
has_filter()
add_filter()
apply_filters()
apply_filters_ref_array()
current_filter()
merge_filters()
remove_filter()
remove_all_filters()

Q2.         What are the template tags in WordPress?


Ans.       A template tag is code that instructs WordPress to “do” or “get” something. Like
in header.php  we will use the tag bloginfo(‘name’) to get “Site Title” from wp-options table
which is set in Setting > General at WordPress dashboard.
The the_title() template tag is used to display the post title.
wp_list_cats() is  for display categories.
get_header() for getting header.
get_sidebar() for display the sidebar on page.
get_footer() for get the footer content on page.

Q3.         how to write the short code in WordPress php file?


Ans.       Using do_shortcode() function inside of php echo tag. A very simple solution is to
use the do_shortcode() function inside a PHP echo tag.
<?php do_shortcode("[shortcode]"); ?>

Q5.         What are the steps you can take if your WordPress file is hacked?
Ans.      
 Install security plugin like WP security
 Re-install the latest version of WordPress
 Change password and user-ids for all your users
 Check your themes and plugins are up to date

Q6.         In which cases you don’t see plugin menu?


Ans.       You can’t see your plugin menu when the blog is hosted on
free wordpress.com as you cannot add plugin there.  Also, if you do not have an account
of an administrator level on your WordPress dashboard, it is not possible to see plugin.

Q7.         What is the difference between the wp_title and the_title tags?
Ans.        wp_title() function is for use outside “The Loop” to display the title of a
Page.  the_title() on the other hand is used within “The Loop“.

Q11.       What do next_posts_link() and previous_posts_link() do?


Ans.        Because post queries are usually sorted in reverse chronological
order, next_posts_link() usually points to older entries (toward the end of the set)
and previous_posts_link() usually points to newer entries (toward the beginning of the
set).

Q15.       How to create Custom Taxonomy specific to a Custom Post type?


Ans.       First of all if you want to show taxonomy metabox only to custom post type then
register the taxonomy to only that custom post type by passing the custom post type
name as argument in register_taxonomy(). By doing this the taxonomy metabox appears
only to custom post type.
Q18.       What’s the difference between site_url() and home_url()?
Ans.       The site_url() will always be the location where you can reach the site by
tacking on /wp-admin on the end, while home_url() would not reliably be this
location. The home_url() would be where you have set your homepage by
setting General > Settings “Site Address (URL)” field.

You might also like