Posts

Showing posts from July, 2021

Wordpress Wpdb->get_results()

  In this Blog We will going to learn everything  about get_results function of wordpress. wpdb->get_results output type : get_results( string $query = null , string   $object = OBJECT ) get_results  takes two arguments as parameter. query and object. query:  it is the sql query you want to run for fetching the results from the database object:  it can take four values ARRAY_A | ARRAY_N | OBJECT | OBJECT_K. You can pass any of these. default value is OBJECT.   it returns the integers index based array of row objects. you can use ->  to access each column field from single row object This Wordpress method returns a returns a complete results set from the database according to the query you are executing from the result set you can extract any specific column value. function show_job_list (){ global $wpdb; $tablename=$wpdb->prefix.' posts '; ob_start(); $posts= $wpdb->get_results( $wpdb->prepare("SELECT job _titl...

How to add php code in wordpress page

Image
 There are several ways for adding php code in wordpress pages. 1. Plugins You can use code snippets plugin in word press. I myself prefer to have more control on the code.So generally I used to avoid plugin and rather write some php code manually. Here I am going to show you both the options.  Go to plugins tab Search for code snippets plugin Install and activate the plugin. After activating you will see a new snippet text appear on the left of the website. click on the snippet and add any php code to it 2. Without Plugin In wordpress there is a concept of short code. You can call  any php code with the help of short code. short code can directly be used in the wordpress website pages. short code can be mapped to any function. add_shortcode('show_post', 'get_all_post'); We have created a short code with name show_post and mapped it to a php function to get all the posts from data base. You can write any php code inside the function depending on your need. Write the...