- When you want to install WordPress, you can change the database prefix (wp_). Because every hacker knows the prefix table name of the database table.
- The essential starting files for a WordPress theme are index.php, style.css, screenshot.png(1200px{w}X900px{h}) and functions.php.
- For visual studio code
- User WordPress Snippets (wpprotools.io) extensions.
- VS Code marks every function as Undefined function
- Click Settings and search for “stubs” then click on “intelephense” extension and then scroll down to bottom. Click add new item and then add wordpress. [Ref:https://wordpress.org/support ]
- <html lang="<?php language_attributes();?>" class="no-js">
- no-js - The previous jQuery file is not allowed.
- <meta charset="<?php bloginfo('charset');?>">
- Add wp_head() and wp_footer();
- The sticky post has the height priority.
- singular.php for the post page. Page.php for the page. Can be
- index.php -->
- Folder Template
- blog_setup.php
- singular.php
- page.php -->
- Folder Template
- page_setup.php
- page.php
- Add body_class(); [<body class="<?php body_class(); ?>"]
- Theme Test Data Master
- https://github.com/WordPress/theme-test-data
- themeunittestdata.wordpress.xml
- https://codex.wordpress.org/Theme_Unit_Test
- Enqueue Function
- function function_name() {}
- First register [except styel.css]
- wp_register_style('custom', get_template_directory_uri().'/assets/css/custom.css', array ('bootstrap'), '5.3.3','all');
- wp_enqueue_style('custom');
- add_action('wp_enqueue_scripts', 'function_name'); -- For Theme Development
- add_action('admin_enqueue_scripts' , 'function_name') -- For Plugin Development
- OOP [For specific situation]
-
function enqueue_action(){
add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts' ))
} -- enqueue_action and enqueue_scripts are function name. Call classname->enqueue_action - Enqueue Style
- wp_enqueue_style( $handle, $src, $deps, $ver, $media );
- wp_enqueue_style( 'myStyle', get_template_directory_uri() . '/css/myCssStyle.css', array('mizan'), '3.3.6', 'all' ); --For Theme Development
- wp_enqueue_style( 'mypluginstyle', plugins_url('/assets/mystyle.css', __FILE__) ); -- For Plugin Development
- You have to enqueue style.css.
- wp_enqueue_style('base_style', get_stylesheet_uri());
- Register not required.
- Enqueue Script
- If you only need to enqueue a script without needing to register it for future use.
- To include jQuery in your project (manually adding isn't required)
- wp_enqueue_script('jquery');
- wp_enqueue_script( $handle, $src, $deps = array(), string|bool|null $var = false, $in_footer = false)
- wp_enqueue_script( 'abc_js', get_template_directory_uri() . '/js/myjs.js', array('jquery'), '3.3.6', true );
- wp_enqueue_script( 'myScript' , plugins_url( '/assets/myscript.js', __FILE__ ) );
- wp_enqueue_style('dashicons');
- Remove Style
- wp_deregister_style( $handle )
- Remove Script
- wp_deregister_script( $handle )
- Image
- <img src="<?php echo get_template_directory_uri(); ?>/assets/img/logo.png" alt="">
WordPress
No comments:
Post a Comment