1<?php
2// 1st Method - Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object
3global $wpdb;
4$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
5
1# Download WordPress Using wp-cli
2wp core download
3
4or
5
6just download zip
7
8https://wordpress.org/download/
1<?php
2add_action( 'admin_init', 'my_admin_samplepost' );
3function my_admin_samplepost() {
4 add_meta_box( 'samplepost_meta_box', 'Car Details', 'display_samplepost_meta_box','samplepost', 'normal', 'high' );
5}
6function display_samplepost_meta_box( $samplepost ) {
7 ?>
8 <h4>General Details</h4>
9 <table width="100%">
10 <tr>
11 <td style="width: 25%">Monthly Paymeny</td>
12 <td><input type="text" style="width:425px;" name="meta[payment]" value="<?php echo esc_html( get_post_meta( $samplepost->ID, 'payment', true ) );?>" />
13 </td>
14 </tr>
15 <tr>
16 <td>Price ($)</td>
17 <td><input type="text" style="width:425px;" name="meta[price]" placeholder="$" value="<?php echo esc_html( get_post_meta( $samplepost->ID, 'price', true ) );?>" />
18 </td>
19 </tr>
20 <tr>
21 <td>Milage</td>
22 <td><input type="text" style="width:425px;" name="meta[milage]" value="<?php echo esc_html( get_post_meta( $samplepost->ID, 'milage', true ) );?>" />
23 </td>
24 </tr>
25 </table>
26<?php
27}
28add_action( 'save_post', 'add_samplepost_fields', 10, 2 );
29function add_samplepost_fields( $samplepost_id, $samplepost ) {
30 if ( $samplepost->post_type == 'samplepost' ) {
31 if ( isset( $_POST['meta'] ) ) {
32 foreach( $_POST['meta'] as $key => $value ){
33 update_post_meta( $samplepost_id, $key, $value );
34 }
35 }
36 }
37}
38
1/*include css from child and parent theme | style.css not updating on WordPress*/
2
3function mychildtheme_enqueue_styles() {
4
5 $parent_style = 'parent-style';
6 wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
7 wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom-style.css', array(), rand(111,9999), 'all' );
8 wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/style.css', array(), rand(111,9999), 'all' );
9
10}
11
12add_action( 'wp_enqueue_scripts', 'mychildtheme_enqueue_styles' ); // register hook
13