How to get post content by usingpost id in wordpress?
Get post content by usingpost id in wordpres function custom_content($post){ $my_postid = 6;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; }
How to create a short code in wordpress?
Create a short code in wordpress function my_shortcode() { //buffering //Object Start ob_start(); date_default_timezone_set(‘asia/kolkata’); //echo date(‘H:i:s’); echo ‘<div id=”mytime”></div>’; // object get contents $output_string = ob_get_contents(); // clean object ob_end_clean(); return $output_string; } add_shortcode(“clock”,”my_shortcode”);
How to get default time by using php?
Get default time by using php date_default_timezone_set(‘asia/kolkata’); <div id=”mytime”>echo date(‘H:i:s’);</div>
A basic example contact from in php and store data from it
A basic example contact from in php and store data from it //contact form in php page <form id=”contact-form” method=”post” action=””> <h2>Contact Us</h2> <div class=”row two-col”> <div class=”first-col”> <label>First Name</label> <input type=”text” name=”firstname” class=”contact-firstname”> <i class=”first-i”></i> </div> <div class=”second-col”> <label>Last Name</label> <input type=”text” name=”lastname” class=”contact-lastname”> <i class=”last-i”></i> </div> </div> <div class=”row two-col”> <div class=”first-col”> <label>Email</label> […]
How to display specific data from custom database table in WordPress?
Display specific data from custom database table in WordPress <table border=”2″> <tr> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Phone</th> <th>Message</th> </tr> <?php global $wpdb; $table_name = $wpdb->prefix . “my_plugintable”; $result = $wpdb->get_results ( “SELECT * FROM $table_name” ); foreach ( $result as $print ) { ?> <tr> <td><?php echo $print->id;?></td> <td><?php echo $print->firstname;?></td> <td><?php echo $print->lastname;?></td> <td><?php […]
How to delete data from database table in wordpress?
Delete data from database table in wordpress <?php if(isset($_POST[“del”])){ global $wpdb; $table_name = $wpdb->prefix . “my_plugintable”; $idval = $_POST[“idval”]; $wpdb->query( $wpdb->prepare( “DELETE FROM $table_name WHERE ID = %d”, $idval)); } get_header(); ?> <table border=”2″ > <tr> <th width=”50px”>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Phone</th> <th>Message</th> <th>Delete</th> </tr> <?php global $wpdb; $table_name = $wpdb->prefix . “my_plugintable”; $result = […]