Professional Documents
Culture Documents
Types of Post Type: Custom Post Types Are New Post Types You Can Create. A Custom Post Type Can Be Added To Wordpress
Types of Post Type: Custom Post Types Are New Post Types You Can Create. A Custom Post Type Can Be Added To Wordpress
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
function create_post_type() {
register_post_type( 'acme_product',
array(
),
);
7) What are the types of hooks in WordPress and mention their functions?
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.
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
Meta-tags are keywords and description used to display website or page information.
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.
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.
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.
$pathname='path/to/directory';
if (!file_exists($pathname)) {
mkdir($pathname, 0777, true);
}
$slug = basename(get_permalink());
OR
$pagename = get_query_var('pagename');
echo bloginfo('version');
define('WP_DEBUG', false );
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
}
global $wpdb;
$lastId = $wpdb->insert_id; //This is last insert id
$obj = get_queried_object();
echo $obj->term_id;
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()
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
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“.