No video

Custom Database Queries in WordPress | WordPress Tutorials

  Рет қаралды 64,349

Joshua Herbison

Joshua Herbison

Күн бұрын

Custom WordPress Database Queries as requested.. Use $wpdb WordPress object to do a database query.
Company Website: www.ideapro.com
SEND BUSINESS CORRESPONDENCE TO:
Idea Pro LLC or Joshua Herbison
2901 E Greenway Rd. #54171
Phoenix, AZ 85032
In my tutorials, you will see me upload files to the server. To upload, I use Sublime Text 3 with SFTP by WBond. idp.bz/sftp
WordPress Codex: idp.bz/wordpres...

Пікірлер: 104
@razakhan3472
@razakhan3472 2 жыл бұрын
Hi, Joshua Herbison I would like to say that you are doing wonderful at educating people I have seen lots of tutorial videos but the way you clear things at a level that even a novice person can understand you (and I love that you don't just assume that the person who is watching have that knowledge already) . Thumbs up and you got a new subscriber. Keep it up and keep bringing these types of videos
@jherbison
@jherbison 2 жыл бұрын
Awesome! Thank you for watching and commenting..
@turb0z
@turb0z Жыл бұрын
I'm doing some custom messaging for a customer in their wordpress environment and this saved me tons of time perusing through the developer documentation. Thank you so much for the thorough explanation. Thought you'd like to know that after 3 years, this video is still providing value!
@jherbison
@jherbison 4 жыл бұрын
Queries can get extensive. If you understand creating custom queries, you can create great dynamic websites far beyond the possibilities of WordPress. Hope you all enjoy the video. Creators that are looking to collaborate with other creators should checkout collab.tube
@AlexHaff
@AlexHaff 2 жыл бұрын
This is immensely helpful - has been more effective for me than some courses. Thank you!
@jherbison
@jherbison 2 жыл бұрын
Thank you for watching and commenting.
@BarisPalabiyik
@BarisPalabiyik 3 жыл бұрын
This was very very well made, and a total lifesaver for many people in various projects Joshua. Keep it up you are helping a lot.
@jherbison
@jherbison 3 жыл бұрын
Thank you for watching and commenting.
@pavman42
@pavman42 Жыл бұрын
This was helpful. I was having issues in-lining php db calls and figured out about 13 minutes into your video that I had a couple of missing semi-colons scattered about. Was able to do what I needed to do w/o all Google misdirection out there. Even found a nice shortcode plugin for php as all the php inline html attempts at presenting table data seemed to fail miserably. While it's still a bit kludgy, and wordpress is still mostly inelegant, at least I can create a data-centric site now. Still beats writing node and a front-end from scratch. Protip: create stored procedures to cut down on the database load with $wpdb calls.
@DManFromMars
@DManFromMars 4 жыл бұрын
Well done. I looked around for this information so much, and this was straight forward and clearly explained.
@jherbison
@jherbison 4 жыл бұрын
Thank you for the comment. Glad you liked it.
@t.w.freiburg6125
@t.w.freiburg6125 4 жыл бұрын
Great! You are a wonderful teacher. Very helpful. Thanks
@jherbison
@jherbison 4 жыл бұрын
Thank you for the compliment and comment.
@philip9677
@philip9677 3 жыл бұрын
I didn’t know you could do sql type queries directly in Wordpress awesome
@jherbison
@jherbison 3 жыл бұрын
Thank you for the comment and watching.
@then8137
@then8137 3 жыл бұрын
DUD ty rrrrrrrrrllllllllly ty you're lookin directly and answer full of the problem more people dont do this ... ty
@jherbison
@jherbison 3 жыл бұрын
Awesome.. Thank you for watching and commenting.
@theman7050
@theman7050 2 жыл бұрын
Great vid again! Would love a custom tables creation and CRUD tutorial in future. :)
@jherbison
@jherbison 2 жыл бұрын
Awesome. Thanks for watching and commenting.
@crazycreativecat
@crazycreativecat 6 ай бұрын
Great tutorial!
@jherbison
@jherbison 5 ай бұрын
Thank you! Thank you for watching and commenting.
@ottavinognata5355
@ottavinognata5355 4 жыл бұрын
Thank you Joshua , these videos are very well made and very usefull. Many thanks.
@jherbison
@jherbison 4 жыл бұрын
Glad you like them. Thank you for watching and commenting.
@jlcdrivewayramps7343
@jlcdrivewayramps7343 3 жыл бұрын
Super clear and easy to understand.!!!!. Thank you.
@jherbison
@jherbison 3 жыл бұрын
Thank you for watching and commenting.. Glad to hear it was clear and easy to understand.
@treycranson
@treycranson 3 жыл бұрын
Sounds like loads of people want to custom query the WP database, but what if we want to query a second database that is holding a dataset unrelated to Wordpress?
@jherbison
@jherbison 3 жыл бұрын
Thank you for the question. It can be done, but you would need to connect to the second database and make sure to not conflict with your current DB connection. I would suggest creating an API style code outside of your WordPress install to the second database and then use something like cURL to pull in that data that you fetch from the cURL command. If you have more details or an example, I could make a video explaining it.
@SkyrimBeast
@SkyrimBeast 3 жыл бұрын
Be wary of using require_once( "wp-load.php" ); Some hosting environments have the root directory WP files symlinked. What this means is the typical WP root directory files won't be where we might think they are. Using require_once() in this fashion, as we saw, will trigger a fatal error every time. Great video though Joshua, many thanks :-)
@jherbison
@jherbison 3 жыл бұрын
When commenting something like that, please explain what they should do instead! Thank you.
@TW-ik3br
@TW-ik3br 4 жыл бұрын
You are awesome. SUBSCRIBED! Keep it rolling. I'm having some issues connecting my gravity form to my own database [not WordPress tables] can you do a video about that? Thank you.
@jherbison
@jherbison 4 жыл бұрын
So is the website WordPress, and then you have a different database that holds the gravity form information?
@dudefromhome
@dudefromhome 4 жыл бұрын
@@jherbison YES. That's is exactly my situation. What options do I have to implement that? FYI: It's also a MySQL database.
@sofakritic6914
@sofakritic6914 4 жыл бұрын
Thats tutorial helped me with my actual website. I use ACF plugin and I Needed to pull out countries from data base. So hard coded countries is possible to pull out, now I need to think how to by switching the countries. Thanks anyway!
@jherbison
@jherbison 4 жыл бұрын
Not exactly sure what you meant, but hope the video helped and thank you for commenting.
@user-vk9or7nn9r
@user-vk9or7nn9r 3 жыл бұрын
Thanks, would be nice to put the data into the admin users panel column, and instead of the post data let's say, take whatever data from database and fill each users row, like ID, but as you explain we will understand how, hehe. I made it myself but couldn't get users data made by other plugin in it's own table. For users ID column there's plenty of tuts.
@jherbison
@jherbison 2 жыл бұрын
Thank you for watching and commenting. I am trying to catch up on comments that I missed.
@abdulrehman5505
@abdulrehman5505 3 жыл бұрын
Good Work, Comment from Pakistan.
@jherbison
@jherbison 3 жыл бұрын
Thank you! Welcome!
@jjsaladins
@jjsaladins 4 жыл бұрын
Thanks for the great content! I've gotten here because I'm running an affiliate program within my website and I'm needing to display specific content within the landing page for each Referror. The use case would be something like this (Jhon enrols to the referral program; Jhon includes a link instead of his home address within the address field; WP Affiliate Manager register Jhon and generates his unique link; Jhon shates his link to Jenna; Jenna cliks on Jhons link; Jenna gets to the LandingPage and sees Jhon's link on a section of the page). Thanks to you I now have and idea on how to resolve the puzzle... If you could help me some more... I'd bee a grateful follower of yours for ever!
@jherbison
@jherbison 4 жыл бұрын
Glad you understand a little more about your solution. Not sure what you need help with. If you need to you can add a function and modify the content with add_filter('the_content','YOUR_FUNCTION_NAME'); Let me know if that makes sense.
@Nazreen
@Nazreen 4 жыл бұрын
Great explanation. Well, put together. 👍
@jherbison
@jherbison 4 жыл бұрын
Thank you for watching and commenting.
@jhjh111
@jhjh111 3 жыл бұрын
Great Video. But I want to hear more about a main wp site and a subdomain wp site sharing data. in other words, I have a wp site installed on a subdomain that I want to query data from the "parent" wp site. Both are using the same data server but individual dbs. you briefly mentioned something about this. any chance you're working on a plugin?
@jherbison
@jherbison 2 жыл бұрын
Thank you. Hope you found a solution for this as I missed your comment. There are many ways to do this. Thank you for watching and commenting.
@DDDD-ns9re
@DDDD-ns9re 4 жыл бұрын
Keep posting Joshua !!
@jherbison
@jherbison 4 жыл бұрын
Thank you. I have some videos in the queue, just haven't had time to get them recorded. Thank you for the comment.
@dkimeiyd
@dkimeiyd 3 жыл бұрын
Thank you so much!
@jherbison
@jherbison 3 жыл бұрын
You're welcome.. Thank you for watching and commenting.
@ivanlik
@ivanlik 3 жыл бұрын
Great! , how we can speed up search in post content ? , that is not indexed ?
@jherbison
@jherbison 3 жыл бұрын
Yes, searching the post_content is slow. I would suggest adding tags to the post for the keywords that are searched most or what words you think are searched for. Not really anyway to speed it up unless you find keywords in the post_content and put those automatically as tags.
@gauravp4468
@gauravp4468 3 жыл бұрын
Cool, can we make section in page or theme customize panel to show content by post type and category like elemntor advance query control
@jherbison
@jherbison 2 жыл бұрын
I hope you found a solution for this.. If not, can you explain a little more about it? Trying to catch up on comments that I missed. Thank you for watching and commenting. If you haven't already, please check out my latest video: A Day In the life of a software engineer. kzfaq.info/get/bejne/kJ53n9h1tpi5XXk.html
@vaibhavp
@vaibhavp 3 жыл бұрын
Hey Joshua, great explanation. I’ve a doubt, I’m using a plug-in to manage custom listings(posts) on my Wordpress website. Now I want to sort these listings by distance. I managed to write a sql query for the same, using which I’m able to fetch the posts ID ordered by distance. Now when I try to fetch posts data using wp query for the corresponding IDs I’m getting them in random order. How can I preserve the order of posts fetched from custom query?
@vaibhavp
@vaibhavp 3 жыл бұрын
Also I’m using get_col() because apparently get_results() was causing critical errors. [undefined function get_results]
@jherbison
@jherbison 3 жыл бұрын
It shouldn’t give you an error of undefined function unless you are calling that function before Wordpress core has loaded the function. It would be interesting to see how your code is setup.
@jherbison
@jherbison 3 жыл бұрын
As far as the query, are you trying to sort by the distance from a given point? Where is the distance stored? As meta value?
@vaibhavp
@vaibhavp 3 жыл бұрын
@@jherbison I can hop on a zoom meeting(screen share) or something if you are available.
@vaibhavp
@vaibhavp 3 жыл бұрын
@@jherbison Yes, starting from a given point. I made a view in the database for the same since the data was scattered all over. And using the sql query in view to sort.
@wastedart1794
@wastedart1794 2 жыл бұрын
Hello Joshua, i have a issue with my get_the__date() gives me the wrong current date, do you know how i can fix this issue, or do you hve any videos covering this? :)
@mastahhdigital4178
@mastahhdigital4178 4 жыл бұрын
Please make the complete course for wordpress
@jherbison
@jherbison 4 жыл бұрын
Thank you for the comment.
@MobiusCoin
@MobiusCoin 4 жыл бұрын
I've always been curious about this but I'm trying to think of situations where I would have to resort to this instead of WP_Query.
@jherbison
@jherbison 4 жыл бұрын
That's cool.. You can use WP_Query.
@danielwatson6529
@danielwatson6529 3 жыл бұрын
5:00 sound like hacking 🤣
@jherbison
@jherbison 3 жыл бұрын
Not hacking at all.. Just writing the code to your benefit.. Hacking would be accessing someone else's admin area... ;-)
@maguilecutty
@maguilecutty 4 жыл бұрын
Dude if you dont already have one, you need to make a udemy course for selling your awesome knowledge!
@jherbison
@jherbison 4 жыл бұрын
Thank you. It isn’t about the money. I enjoy helping others. If I did it as a course on udemy, then it would become a job! Thank you for the comment.
@chuksezeilo
@chuksezeilo 4 жыл бұрын
@@jherbison interesting perspective! I actually jump out of the Udemy course to come here and get some clarification. Your pace is so much more natural. I guess your perspective on doing the videos is the reason why you do them so well.
@salmanrazakmemon
@salmanrazakmemon 4 жыл бұрын
hi, how to show woocommerce product inventory (counter). i am integrating POS with online store. Based on my POS quantity I want to change website inventory stock.
@jherbison
@jherbison 4 жыл бұрын
I have not dug into woocommerce that much as I don't like it. I have only been in to fix errors. If I get time, I will take a look at it and see how to update the quantity. Thank you for watching and commenting.
@pawanmaurya7146
@pawanmaurya7146 3 жыл бұрын
this tutorial was very helpful I need your help in the same kind of project. can you help me?
@jherbison
@jherbison 3 жыл бұрын
Hope you were able to figure out your project.. Thank you for watching and commenting.
@timr5078
@timr5078 4 жыл бұрын
including wp-load.php does not work with Updated WP 5.4, on my local machine with php 5 something, but on previous vesions is ok
@jherbison
@jherbison 4 жыл бұрын
You should be using php 7 at minimum. It should work on all versions of WordPress since about version 4.. Maybe the path is wrong. Hope you were able to figure it out. Thank you for watching and commenting.
@ShannonWhitty
@ShannonWhitty 4 жыл бұрын
Do you have any guides that show how you call this through an Ajax call? I am building an Admin page using DataTables with the data being loaded via an Ajax call. But the Ajax page has no WP loaded
@jherbison
@jherbison 4 жыл бұрын
On the ajax page that is loaded, use require_once('PATH_TO_ROOT_WORDPRESS_FOLDER/wp-load.php'); Then WordPress is loaded on that page.
@ShannonWhitty
@ShannonWhitty 4 жыл бұрын
​@@jherbison Thanks for replying. I went onto to some other tutorials and learnt about admin-ajax.php and nonce and have built my very first plugin. Will have to show you sometime
@timsteeman8847
@timsteeman8847 2 жыл бұрын
Hi Joshua, which php-editor are using?
@jherbison
@jherbison 2 жыл бұрын
Sublime text
@jherbison
@jherbison 2 жыл бұрын
Thank you for watching and commenting.
@timsteeman8847
@timsteeman8847 2 жыл бұрын
@@jherbison Thank you
@kulvindersingh2738
@kulvindersingh2738 4 жыл бұрын
Thank you sir !
@jherbison
@jherbison 4 жыл бұрын
You’re welcome. Hope it helped. Please share the video with anyone that it can help. I really want to start growing the channel but need more subs and views. Thank you for your help and comment.
@kulvindersingh2738
@kulvindersingh2738 4 жыл бұрын
@@jherbison sure sir!
@bonniesitessolutions7728
@bonniesitessolutions7728 3 жыл бұрын
There has been a recent update to Wordpress core, about a week ago. Is this still safe to use and won't break anything?
@jherbison
@jherbison 3 жыл бұрын
Yes, it still works and should not break anything unless you write the query wrong.. I would always do it in a dev staging area before doing it on a live website. Thank you for watching and commenting.
@bonniesitessolutions7728
@bonniesitessolutions7728 3 жыл бұрын
@@jherbison Thanks for the quick reply!
@bonniesitessolutions7728
@bonniesitessolutions7728 3 жыл бұрын
@@jherbison ps: your tubebuddy link is broken
@jherbison
@jherbison 3 жыл бұрын
Yeah, I need to remove it. I stopped using TubeBuddy as it was too expensive for what I was getting out of it. Thank you for letting me know. Forgot it was even still a link on the description.
@jherbison
@jherbison 3 жыл бұрын
Your welcome. Sometimes I have more time to reply then other times.
@passionartw
@passionartw 4 жыл бұрын
is this method works with products also?
@jherbison
@jherbison 4 жыл бұрын
Yes, you should be able to query any information in the database. Thank you for the comment.
@raywebb8215
@raywebb8215 4 жыл бұрын
I have a question.... where are you doing this from?
@jherbison
@jherbison 4 жыл бұрын
Do you mean location? If so, my home office in Scottsdale Arizona.
@raywebb8215
@raywebb8215 4 жыл бұрын
I was more interested in a directory path but I’ll type in your city and state and see what I get... 😉
@edington6302
@edington6302 3 жыл бұрын
My database failing to connect even after following step by step.
@jherbison
@jherbison 3 жыл бұрын
Can you email me your code to josh@ideapro.com so I can see what is happening? Thank you for watching and commenting.
@ValtrX
@ValtrX 3 жыл бұрын
Thank you so much!
@jherbison
@jherbison 2 жыл бұрын
Thank you for watching and commenting.. Trying to catch up on comments.
The Basics of Dynamic Content in 15 Minutes
18:16
Rino de Boer
Рет қаралды 178 М.
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 10 МЛН
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 49 МЛН
Form Submit Using Ajax - WordPress Form Ajax
1:09:25
Joshua Herbison
Рет қаралды 18 М.
How to migrate from a custom database into WordPress
14:11
Toolset
Рет қаралды 36 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 353 М.
File Upload Using A Form Submit - WordPress Plugin Development Form
21:01
Custom tables in WordPress
1:06:58
WordPress
Рет қаралды 2,1 М.
WordPress Database High-Level Tour
15:27
WPCasts
Рет қаралды 13 М.
you need to learn SQL RIGHT NOW!! (SQL Tutorial for Beginners)
24:25
NetworkChuck
Рет қаралды 1,5 МЛН
How to Save Elementor Form Data to Your Database
12:45
Tony Teaches Tech
Рет қаралды 86 М.
WordPress Block Theme Development
47:33
Elliott Richmond
Рет қаралды 22 М.