Posts

How to Create Custom form in Wordpress without plugin

Image
How to create Custom form in wordpress without plugin: Although while building a website with wordpress there are many wordpress plugins which can be used to create wordpress forms for wordpress website like wp_forms  wp_forms ,gravity forms   Gravity forms ,ninja forms  Ninja forms . So you can use these wordpress plugins as well but I personally feels that it's easy to make any change in your code instead of changing wordpress plugins code.In this article we will see how to create custom wordpress form without plugin. Clean Approach for creating custom wordpress form: Keep only html code inside the wordpress form page Keep all the css inside wordpress style.css file. Keep PHP functions inside wordpress functions.php .  if the core logic is separate from the appearance of the form than it is easy to maintain the code in long run.  Putting the core logic, cosmetics and appearance in same page make it difficult to manage the code in long run.You can think ...

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...