{"id":14054,"date":"2015-04-10T05:05:43","date_gmt":"2015-04-09T19:05:43","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=14054"},"modified":"2015-04-10T05:05:43","modified_gmt":"2015-04-09T19:05:43","slug":"wordpress-blog-category-list-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-category-list-primer-tutorial\/","title":{"rendered":"WordPress Blog Category List Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/CategoryList\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"WordPress Blog Category List Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/CategoryList\/Category_Software_Sticky-00of.jpg\" title=\"WordPress Blog Category List Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">WordPress Blog Category List Primer Tutorial<\/p><\/div>\n<p>You may well be aware that a WordPress blog, such as the one you are viewing, has a MySql database which is like its signature &#8230; well, more than a signature &#8230; basically most of its identity, because no matter what styling and theming you apply (and in any case some of the styling and theming ideas get stored in the database as well) the data behind the blog is what makes it what it is.<\/p>\n<p>The WordPress PHP software has a <a target=_blank title='Fred and Ginger' href='http:\/\/www.youtube.com\/watch?v=ydxcHACwX4Y'>&#8220;Fred and Ginger&#8221;<\/a> relationship with its MySql database.  Who&#8217;s Fred, and who&#8217;s Ginger? &#8230; leave that for you.<\/p>\n<p>But as with most decent dances you used to be able to tap somebody on the shoulder and ask for a changed arrangement &#8230; are you all rolling around on the floor yet? &#8230; the older of us have gone to the fridge to get a banana muffin I expect?!<\/p>\n<p>Anyway, to cut a long story short, we are going to separate ourselves from WordPress PHP, and write our own, that sits outside and makes changes to the WordPress blog by adjusting the WordPress blog&#8217;s MySql database from this removed position.  Okay, if you want to be dramatic &#8230; &#8220;in a backdoor way&#8221;.  And what do you need to do this?<\/p>\n<ul>\n<li>MySql hostname<\/li>\n<li>MySql username<\/li>\n<li>MySql password<\/li>\n<li>MySql database name<\/li>\n<\/ul>\n<p> &#8230; in order to make a connection to the MySql database from PHP.  This word &#8220;connection&#8221; is absolutely massive in the Information Technology world, because the Information Technology world is increasingly about networking and devices and synchronicity and data and databases and services, but bear in mind (all) this networking was once a secretive and arcane &#8220;art&#8221;, so things have come along\/&#8221;a long way&#8221; (chortle, chortle).  Wonder what the sky would look like if every message we sent via a connection had a unique streaky air-dye colour as it streaked through the atmosphere?<\/p>\n<p>Okay, for the point of today&#8217;s mission &#8230; we want to end up with a comma delimited list of blog posting ID numbers that all belong to a category of interest (and that are <a target=_blank title='MySql help for the more than 8 days bit ... thanks' href='http:\/\/www.techonthenet.com\/mysql\/functions\/datediff.php'>more than 8 days old<\/a> &#8230; thanks).<\/p>\n<p>That last bit probably gives the game away, but, nevertheless we&#8217;ll leave it until tomorrow to let you know how this functionality could be of use.<\/p>\n<p>By the way, if you were within WordPress PHP code you could use the <a target=_blank title='WordPress get_posts() method' href='https:\/\/codex.wordpress.org\/Template_Tags\/get_posts'><i>&#8220;get_posts()&#8221;<\/i><\/a> functionality to achieve this as well, I think.<\/p>\n<p>There is, what seems to me, a logical approach to achieving this &#8230;<\/p>\n<ul>\n<li>create a piece of SQL (an example of which we&#8217;ve saved for your perusal you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/software_posts.sql_GETME\" title='software_posts.sql'>software_posts.sql<\/a>) that will get those ID numbers of a particular category older than 8 days, and for great help here would like to thank this very <a target=_blank title='Useful link' href='https:\/\/wordpress.org\/support\/topic\/sql-query-to-get-all-posts-from-a-category'>useful link<\/a> from WordPress.org support forum (thanks) &#8230; in order to achieve this we use the incredible, the marvellous, the witty (you had to be there), the curiously refreshing <a target=_blank title='phpMyAdmin landing page' href='http:\/\/www.phpmyadmin.net\/'><i>&#8220;phpMyAdmin&#8221;<\/i><\/a> &#8230; read more <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=phpMyAdmin\" title=\"phpMyAdmin at this blog\">here<\/a><\/li>\n<li>take another piece of PHP that did something like what we want to do today &#8230; do you remember <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php_GETME\" title='tutorial_options.php'>tutorial_options.php<\/a> (from <a target=_blank href=\"v chttp:\/\/www.rjmprogramming.com.au\/wordpress\/?s=tutorial_options.php_GETME\" title='tutorial_options.php mentions'>here<\/a>)? &#8230; and plug in the SQL and modify the rest to end up with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/category_software_list.php_GETME\" title='category_software_list.php'>category_software_list.php<\/a> &#8230; store the results in a file you can see at <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/software_posts_list.php\" title='software_posts_list.php'>software_posts_list.php<\/a><\/p>\n<\/ul>\n<p>So we hope to see you back here tomorrow to complete the loop, and in the meantime you might like to review today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/CategoryList\/\" title='Click picture'>tutorial<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d14054' onclick='var dv=document.getElementById(\"d14054\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=SQL\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14054' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>You may well be aware that a WordPress blog, such as the one you are viewing, has a MySql database which is like its signature &#8230; well, more than a signature &#8230; basically most of its identity, because no matter &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-category-list-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12,37],"tags":[151,252,299,827,932,938,997,1018,1186,1319,1456],"class_list":["post-14054","post","type-post","status-publish","format-standard","hentry","category-database","category-elearning","category-tutorials","tag-blog","tag-connection","tag-database-2","tag-mysql","tag-php","tag-phpmyadmin","tag-programming","tag-query","tag-sql","tag-tutorial","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14054"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=14054"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14054\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=14054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=14054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=14054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}