get_header()
get_footer()
// Start the loop. while ( have_posts() ) : the_post(); // Include the page content template. get_template_part( 'content', 'page' ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; // End the loop.
$args = array( 'posts_per_page' => '-1', 'post_type' => 'products' ); $myProducts = new WP_Query( $args ); while ( $myProducts->have_posts() ) : $myProducts->the_post(); get_template_part( 'content', get_post_format() ); endwhile; wp_reset_postdata();
global $wpdb; $results = $wpdb->get_results( 'SELECT a.name FROM wp_terms a,wp_term_taxonomy b,wp_term_relationships c WHERE a.term_id=b.term_id and b.term_taxonomy_id= c.term_taxonomy_id and c.object_id ='.get_the_ID().'');
the_content(); get_the_content();
get_the_ID()
is_home()
is_front_page()
is_single()
single_post_title()
the_title()
the_post_thumbnail( array( 100, 100 ) ); the_post_thumbnail( 'medium' ); // Medium resolution (300 x 300 max height 300px) the_post_thumbnail( 'medium_large' ); // Medium Large (added in WP 4.4) resolution (768 x 0 infinite height) has_post_thumbnail($post->ID) get_the_post_thumbnail($post->ID)
the_meta();
// Get a specific custom field information echo get_post_meta( $post->ID, 'movie type', TRUE ); // post id, custom_field_name, $single boolean value
add_post_meta( int $post_id, string $meta_key, mixed $meta_value, bool $unique = false )
add_meta( int $post_ID )
add_metadata( string $meta_type, int $object_id, string $meta_key, mixed $meta_value, bool $unique = false )
Custom Field Rating: esc_html( get_post_meta( get_the_ID(), 'movie_rating', true ) )
add_meta_box( string $id, string $title, callable $callback, string|array|WP_Screen $screen = null, string $context = 'advanced', string $priority = 'default', array $callback_args = null )
get_field('field_5b69fa7399d20') /*or wordpress 5.0*/ get_post_meta( post_id, 'field_name', TRUE )
get_field('field_5b69fa7399d20')['url'] /*or wordpress 5.0*/ get_field('fiels_name',post_id)['url'];
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentyfifteen' ),
'next_text' => __( 'Next page', 'twentyfifteen' ),
'before_page_number' => '
',
));
$category_list = wp_list_categories( array( 'taxonomy' => 'ukmcategory', 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'echo' => 0, 'title_li' => 'Category' ) ); // Make sure there are terms with articles if ( $category_list ) echo '
if ( has_nav_menu( 'primary' ) ) : wp_nav_menu( array( 'menu_class' => 'nav-menu', 'theme_location' => 'primary', )); endif;
//dynamic_sidebar( int|string $index = 1 ) if ( is_active_sidebar( 'sidebar-1' ) ) : dynamic_sidebar( 'sidebar-1' ); endif;
the_permalink()
esc_url( home_url( '/' ) )
bloginfo( string $show = '' )
get_bloginfo('stylesheet_directory').'/images/down.png' get_bloginfo('template_directory') . '/images/down.png'
wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback, $callback_args )
function wpb_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(" SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish' "); $output = ''; if($copyright_dates) { $copyright = "© " . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= '-' . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; }
After adding this function, you’ll need to open your footer.php file and add the following code wherever you like to display the dynamic copyright date:
echo wpb_copyright();
First you need to add this code to your theme’s functions file.
function wpb_bg() { $rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); $color ='#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)]. $rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)]; echo $color; }
Next, you’ll need to edit the header.php file in your theme. Locate the
tag and add replace it with this line: <body <?php body_class(); ?> style="background-color:<?php wpb_bg();?>">>One way to do this is by using wp-config.php file. However, if you do that you will not be able to set the correct address on the settings page. The WordPress URL and Site URL fields will be locked and uneditable
If you want to fix this, then you should add this code to your functions file.
update_option( 'siteurl', 'http://example.com' ); update_option( 'home', 'http://example.com' );
Don’t forget to replace example.com with your own domain name.
WordPress automatically creates several image sizes when you upload an image. You can also create additional image sizes to use in your theme. Add this code your theme’s functions file.
add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode
You can display an image size in anywhere in your theme using this code
<?php the_post_thumbnail( 'homepage-thumb' ); ?>WordPress allows theme developers to define navigation menus and then display them. Add this code in your theme’s functions file to define a new menu location in your theme.
function wpb_custom_new_menu() { register_nav_menu('my-custom-menu',__( 'My Custom Menu' )); } add_action( 'init', 'wpb_custom_new_menu' );
Now you need to add this code to your theme where you want to display navigation menu.
<?php wp_nav_menu( array( 'theme_location' => 'my-custom-menu', 'container_class' => 'custom-menu-class' ) ); ?>This is one of the most used ones and many developers already know about this. But it deserves to be in this list for those who don’t know. Paste the following code in your functions.php file:
register_sidebar( array|string $args = array() ) function custom_sidebars() { $args = array( 'id' => 'custom_sidebar', 'name' => __( 'Custom Widget Area', 'text_domain' ), 'description' => __( 'A custom widget area', 'text_domain' ), 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', ); register_sidebar( $args ); } add_action( 'widgets_init', 'custom_sidebars' );
To display this sidebar or widget ready area in your theme add this code:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom_sidebar') ) : ?> dynamic_sidebar('custom_sidebar') <?php endif; ?>function wp_welcome_panel() { echo "Hi Dashboard"; }
add_user()
auth_redirect()
cache_users( array $user_ids )
edit_user( int $user_id )
check_import_new_users( string $permission )
check_password_reset_key( string $key, string $login )
confirm_delete_users( array $users )
confirm_user_signup( string $user_name, string $user_email )
create_user( string $username, string $password, string $email ) function wp_create_user($username, $password, $email = '') { $user_login = wp_slash( $username ); $user_email = wp_slash( $email ); $user_pass = $password; $userdata = compact('user_login', 'user_email', 'user_pass'); return wp_insert_user($userdata); }
delete_all_user_settings()
download_url( string $url, int $timeout = 300 )
add_user_meta( int $user_id, string $meta_key, mixed $meta_value, bool $unique = false )
$usercount = count_users(); $result = $usercount['total_users'];
count_user_posts( int $userid, array|string $post_type = 'post', bool $public_only = false )
get_current_user_id()
$image_set = get_option( 'image_default_link_type' ); if ($image_set !== 'none') { update_option('image_default_link_type', 'none'); }
add_role( string $role, string $display_name, array $capabilities = array() )
//get_the_author_meta( string $field = '', int $user_id = false ) get_the_author_meta( 'display_name', $post->post_author ); // get_author_posts_url( int $author_id, string $author_nicename = '' ) get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
absint( mixed $maybeint ) echo absint( -10 );
activate_plugin( string $plugin, string $redirect = '', bool $network_wide = false, bool $silent = false )
activate_plugins( string|array $plugins, string $redirect = '', bool $network_wide = false, bool $silent = false )
addslashes_gpc( string $gpc )
add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
add_blog_option( int $id, string $option, mixed $value )
add_clean_index( string $table, string $index )
add_comments_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' )
add_comment_meta( int $comment_id, string $meta_key, mixed $meta_value, bool $unique = false )
add_contextual_help( string $screen, string $help )
add_cssclass( string $add, string $class )
add_custom_background( callable $wp_head_callback = '', callable $admin_head_callback = '', callable $admin_preview_callback = '' )
add_custom_image_header( callable $wp_head_callback, callable $admin_head_callback, callable $admin_preview_callback = '' )
add_dashboard_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function register_my_custom_menu_page(){ add_dashboard_page( 'custom menu title', 'Test', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'test/images/icon.png' ), 6 ); } function my_custom_menu_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Test</h2>'; echo 'Test'; echo '</div>'; } add_action( 'admin_menu', 'register_my_custom_menu_page' );
add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '', int $position = null )
add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output_page','icon_url' ,'position'); add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my-menu1','my_menu_page' ); add_submenu_page('my-menu', 'Submenu Page Title2', 'Whatever You Want2', 'manage_options', 'my-menu2','my_menu2_page'); } function my_menu_output_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>my_menu_output_page</h2>'; echo 'Test'; echo '</div>'; } function my_menu_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>my-menu1</h2>'; echo 'Test'; echo '</div>'; } function my_menu2_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>my-menu2</h2>'; echo 'Test'; echo '</div>'; }
add_management_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function register_my_tools_page(){ add_management_page( 'tool page title', 'tools page', 'manage_options', 'customtool', 'my_custom_tool_page'); } function my_custom_tool_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom Tool</h2>'; echo 'tool page'; echo '</div>'; } add_action( 'admin_menu', 'register_my_tools_page' );
add_options_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function my_custom_setting_page(){ add_options_page( 'setting page title', 'setting page', 'manage_options', 'customsetting', 'my_custom_sett_page'); } function my_custom_sett_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom Setting</h2>'; echo 'Setting Page'; echo '</div>'; } add_action( 'admin_menu', 'my_custom_setting_page' );
add_pages_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function my_custom_paged_page(){ add_pages_page( 'page page title', 'page page', 'manage_options', 'custompage', 'my_custom_page_page'); } function my_custom_page_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom page</h2>'; echo 'pagepage'; echo '</div>'; } add_action( 'admin_menu', 'my_custom_paged_page' );
add_plugins_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function my_custom_plugin_page(){ add_plugins_page( 'plug page title', 'plug page', 'manage_options', 'customplug', 'my_custom_plug_page'); } function my_custom_plug_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom plug</h2>'; echo 'plug page'; echo '</div>'; } add_action( 'admin_menu', 'my_custom_plugin_page' );
add_posts_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function my_custom_post_page(){ add_posts_page( 'post page title', 'post page', 'manage_options', 'custompost', 'my_custom_po_page'); } function my_custom_po_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom post</h2>'; echo 'post page'; echo '</div>'; } add_action( 'admin_menu', 'my_custom_post_page' );
add_media_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function register_my_media_page(){ add_media_page( 'media page title', 'media page', 'manage_options', 'custommedia', 'my_custom_media_page'); } function my_custom_media_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom media</h2>'; echo 'tool page'; echo '</div>'; } add_action( 'admin_menu', 'register_my_media_page' );
add_theme_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function register_my_theme_page(){ add_theme_page( 'theme page title', 'theme page', 'manage_options', 'customtheme', 'my_custom_them_page'); } function my_custom_them_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom theme</h2>'; echo 'theme page'; echo '</div>'; } add_action( 'admin_menu', 'register_my_theme_page' );
add_users_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' ) function register_my_user_page(){ add_users_page( 'user page title', 'user page', 'manage_options', 'customuser', 'my_custom_us_page'); } function my_custom_us_page(){ echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>Custom user</h2>'; echo 'user page'; echo '</div>'; } add_action( 'admin_menu', 'register_my_user_page' );
add_editor_style( array|string $stylesheet = 'editor-style.css' )
add_existing_user_to_blog( array $details = false )
add_feed( string $feedname, callable $function )
add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
apply_filters( string $tag, mixed $value )
add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
add_link()
add_links_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' )
add_magic_quotes( array $array )
add_menu_classes( array $menu )
add_network_option( int $network_id, string $option, mixed $value )
add_new_user_to_blog( int $user_id, mixed $password, array $meta )
add_object_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '' )
add_object_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '' )
add_option_update_handler( string $option_group, string $option_name, callable $sanitize_callback = '' )
add_option_whitelist( array $new_options, string|array $options = '' )
add_permastruct( string $name, string $struct, array $args = array() )
add_ping( int|WP_Post $post_id, string|array $uri )
add_ping( int|WP_Post $post_id, string|array $uri )
add_post_type_support( string $post_type, string|array $feature )
add_query_arg()
add_rewrite_endpoint( string $name, int $places, string|bool $query_var = true )
add_rewrite_rule( string $regex, string|array $query, string $after = 'bottom' )
add_rewrite_tag( string $tag, string $regex, string $query = '' )
add_rewrite_tag( string $tag, string $regex, string $query = '' )
add_settings_field( string $id, string $title, callable $callback, string $page, string $section = 'default', array $args = array() )
add_settings_section( string $id, string $title, callable $callback, string $page )
add_shortcode( string $tag, callable $callback )
do_shortcode( string $content, bool $ignore_html = false )
admin_url( string $path = '', string $scheme = 'admin' )
body_class( string|array $class = '' )
check_upload_mimes( array $mimes )
check_upload_mimes( array $mimes )
check_upload_size( array $file )
current_action()
current_filter()
current_time( string $type, int|bool $gmt )
do_robots()
esc_html( string $text )
esc_sql( string|array $data )
esc_textarea( string $text )
esc_url( string $url, array $protocols = null, string $_context = 'display' )
file_is_displayable_image( string $path )
file_is_valid_image( string $path )
force_ssl_login( string|bool $force = null )
format_to_post( string $content )
format_to_post( string $content )
generate_random_password( int $len = 8 )
get_available_languages( string $dir = null )
get_available_post_mime_types( string $type = 'attachment' )
get_available_post_mime_types( string $type = 'attachment' )
get_avatar( mixed $id_or_email, int $size = 96, string $default = '', string $alt = '', array $args = null )
get_avatar( mixed $id_or_email, int $size = 96, string $default = '', string $alt = '', array $args = null )
get_categories( string|array $args = '' )
get_category( int|object $category, string $output = OBJECT, string $filter = 'raw' )
get_cat_ID( string $cat_name )
get_cat_name( int $cat_id )
get_date_from_gmt( string $string, string $format = 'Y-m-d H:i:s' )
get_home_path()
get_home_url( int $blog_id = null, string $path = '', string|null $scheme = null )
get_last_updated( mixed $deprecated = '', int $start, int $quantity = 40 )
add_theme_support( string $feature )
wp_enqueue_style( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, string $media = 'all' )
wp_enqueue_script( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, bool $in_footer = false ))
get_template_directory_uri()
get_stylesheet_uri()
wp_style_add_data( string $handle, string $key, mixed $value )
wp_localize_script( string $handle, string $object_name, array $l10n )
Total : 26654
Today :3
Today Visit Country :