{"id":3324,"date":"2019-06-16T15:55:01","date_gmt":"2019-06-16T12:55:01","guid":{"rendered":"https:\/\/sitecenneti.com\/wordpress\/?p=3324"},"modified":"2019-06-20T02:04:45","modified_gmt":"2019-06-19T23:04:45","slug":"get_children","status":"publish","type":"post","link":"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_children\/","title":{"rendered":"Get_children()"},"content":{"rendered":"<div id=\"toc_container\" class=\"toc_transparent no_bullets\"><p class=\"toc_title\">BU DERS\u0130N BA\u015eLIKLARI<\/p><ul class=\"toc_list\"><li><a href=\"#Aciklamasi\"><span class=\"toc_number toc_depth_1\">1<\/span> A\u00e7\u0131klamas\u0131:<\/a><\/li><li><a href=\"#Parametreleri\"><span class=\"toc_number toc_depth_1\">2<\/span> Parametreleri:<\/a><ul><li><a href=\"#argumanlar\"><span class=\"toc_number toc_depth_2\">2.1<\/span> $argumanlar<\/a><ul><li><a href=\"#Ornek-1\"><span class=\"toc_number toc_depth_3\">2.1.1<\/span> \u00d6rnek-1<\/a><\/li><\/ul><\/li><li><a href=\"#dizinin_bicimi\"><span class=\"toc_number toc_depth_2\">2.2<\/span> $dizinin_bicimi<\/a><ul><li><a href=\"#Ornek-1-2\"><span class=\"toc_number toc_depth_3\">2.2.1<\/span> \u00d6rnek-1<\/a><\/li><li><a href=\"#Ornek-2\"><span class=\"toc_number toc_depth_3\">2.2.2<\/span> \u00d6rnek-2<\/a><\/li><li><a href=\"#Ornek-3\"><span class=\"toc_number toc_depth_3\">2.2.3<\/span> \u00d6rnek-3<\/a><\/li><\/ul><\/li><\/ul><\/li><li><a href=\"#Dondurdugu_Sonuc\"><span class=\"toc_number toc_depth_1\">3<\/span> D\u00f6nd\u00fcrd\u00fc\u011f\u00fc Sonu\u00e7:<\/a><\/li><li><a href=\"#Kaynak_Kodu\"><span class=\"toc_number toc_depth_1\">4<\/span> Kaynak Kodu:<\/a><\/li><\/ul><\/div>\n\n<pre class=\"wp-block-code\"><code>get_children( mixed $argumanlar = '', string $dizinin_bicimi = OBJECT )<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Aciklamasi\">A\u00e7\u0131klamas\u0131:<\/span><\/h2>\n\n\n\n<p>WordPress ile, standart olarak olu\u015fturulabilen 5 fakl\u0131 <a rel=\"noreferrer noopener\" aria-label=\"i\u00e7erik tiplerinden (yeni sekmede a\u00e7\u0131l\u0131r)\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-tema-yapimi\/2-3-icerik-tipleri-post-types\/\" target=\"_blank\">i\u00e7erik tipinden<\/a> ikisi, <em>sayfa<\/em> ve <em>yaz\u0131lard\u0131r<\/em>. Sayfa ve yaz\u0131lar\u0131n, di\u011fer \u00fc\u00e7 i\u00e7erik tipinden farkl\u0131 olarak, ebeveyn olma \u00f6zellikleri vard\u0131r, yani yavrulara sahip olabilirler. Bir sayfan\u0131n yavrusu, bir ba\u015fka sayfa ya da sayfalard\u0131r, bir yaz\u0131n\u0131n yavrusu ise, o yaz\u0131y\u0131 d\u00fczenlerken y\u00fcklenen, bir veya daha fazla ortam dosyas\u0131d\u0131r. Bir yaz\u0131 ya da sayfan\u0131n yavrular\u0131n\u0131 getirmek i\u00e7in kullan\u0131labilecek fonksiyonlardan biri de <code>get_children()<\/code> fonksiyonudur.<\/p>\n\n\n\n<p><code>Get_children()<\/code> fonksiyonu, <a rel=\"noreferrer noopener\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_posts-fonksiyonu\/\" target=\"_blank\">get_posts()<\/a> fonksiyonundan t\u00fcretilmi\u015ftir. Bu y\u00fczden, <code>get_children()<\/code> fonksiyonunu anlamak i\u00e7in \u00f6nce <a rel=\"noreferrer noopener\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_posts-fonksiyonu\/\" target=\"_blank\">get_posts()<\/a> fonksiyonunu anlamak gerekir.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Parametreleri\">Parametreleri:<\/span><\/h2>\n\n\n\n<p><code>Get_children()<\/code> fonksiyonu, iki parametre al\u0131r. Bu parametrelerin ikisi de iste\u011fe ba\u011fl\u0131d\u0131r. Bunlardan ilki <code>$argumanlar<\/code> parametresi, di\u011feri ise <code>$dizinin_bicimi<\/code> parametresidir. Parametreleri yak\u0131nda inceleyelim:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"argumanlar\">$argumanlar<\/span><\/h3>\n\n\n\n<p>(<em>Zorunlu de\u011fildir<\/em>) <code>get_children()<\/code> fonksiyonu, <a rel=\"noreferrer noopener\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_posts-fonksiyonu\/\" target=\"_blank\">get_posts()<\/a> fonksiyonunun kulland\u0131\u011f\u0131 arg\u00fcmanlar\u0131 kullan\u0131r. Fakat, <code>get_children()<\/code> fonksiyonu, <a rel=\"noreferrer noopener\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_posts-fonksiyonu\/\" target=\"_blank\">get_posts()<\/a> fonksiyonundan farkl\u0131 olarak, baz\u0131 arg\u00fcmanlar i\u00e7in farkl\u0131 varsay\u0131lan de\u011ferleri kullan\u0131r. Bu iki fonksiyon aras\u0131ndaki temel fark\u0131 olu\u015fturan bu arg\u00fcmanlar, her iki fonksiyonun kulland\u0131\u011f\u0131 varsay\u0131lan de\u011ferleri ile birlikte a\u015fa\u011f\u0131da verilmi\u015ftir:<\/p>\n\n\n\n<p><code>Get_children()<\/code> fonksiyonundaki varsay\u0131lan de\u011ferleri:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'numberposts' => -1, \/\/ B\u00fct\u00fcn i\u00e7erikleri getir\n'post_type'   => 'any', \/\/ B\u00fct\u00fcn i\u00e7erik tiplerini getir\n'post_status' => 'any', \/\/ Durumu ne olursa olsun getir\n'post_parent' => 0, \/\/ Yavrular\u0131 getirme<\/code><\/pre>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/sitecenneti.com\/wordpress\/wordpress-fonksiyonlari\/get_posts-fonksiyonu\/\" target=\"_blank\">get_posts()<\/a> fonksiyonundaki varsay\u0131lan de\u011ferleri:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'numberposts' => 5, \/\/ Son be\u015f i\u00e7eri\u011fi getir\n'post_type'   => 'post', \/\/ Sadece tipi \"yaz\u0131\" olanlar\u0131 getir\n'post_status' => 'publish', \/\/ Yay\u0131nlanm\u0131\u015fsa getir\n'post_parent' => '', \/\/ Yavru ya da ebeveyn olabilir<\/code><\/pre>\n\n\n\n<p>Yukar\u0131da verilen 4 arg\u00fcman d\u0131\u015f\u0131nda, di\u011fer b\u00fct\u00fcn arg\u00fcmanlar\u0131n kullan\u0131m\u0131 ve varsay\u0131lan de\u011ferleri her iki fonksiyonda da ayn\u0131d\u0131r.<\/p>\n\n\n\n<p class=\"sc-dikkat\"><code>Get_children()<\/code> fonksiyonunun, ad\u0131nda vaadetti\u011fi gibi, yavru i\u00e7erikleri getirmesi i\u00e7in, <code>'post_parent'<\/code> arg\u00fcman\u0131 kullan\u0131lmal\u0131d\u0131r. Bu arg\u00fcmana, yavrular\u0131n\u0131 getirmek istedi\u011fimiz i\u00e7eri\u011fin ID de\u011feri verilmelidir.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span id=\"Ornek-1\">\u00d6rnek-1<\/span><\/h4>\n\n\n\n<p>A\u015fa\u011f\u0131daki \u00f6rnek, <em>ID<\/em> de\u011feri <em>1810<\/em> olan bir yaz\u0131ya ait ortam dosyalar\u0131n\u0131 getirir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment', \/\/ sadece resimleri getir\n\t'post_parent' => 1810, \/\/ ID de\u011feri 1810 olan i\u00e7erik i\u00e7in y\u00fcklenen resimleri getir\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar);<\/code><\/pre>\n\n\n\n<p>Yukar\u0131daki kod, ID de\u011feri 1810 olan bir i\u00e7erik i\u00e7in y\u00fcklenmi\u015f ortam dosyalar\u0131n\u0131n hepsini getirir ve <code>$gelen_resimlerin_dizisi<\/code> de\u011fi\u015fkenine bir dizi olarak y\u00fckler. Bu dizinin, hangi \u015fekilde ve hangi bilgiler ile geldi\u011fini g\u00f6rmek i\u00e7in <code>var_dump()<\/code> fonksiyonunu kullanabiliriz. \u015e\u00f6yle ki:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var_dump($gelen_resimlerin_dizisi);<\/code><\/pre>\n\n\n\n<p>Yukar\u0131daki <code>var_dump()<\/code> fonksiyonu, a\u015fa\u011f\u0131daki diziyi bast\u0131racakt\u0131r.(Dizi daha anla\u015f\u0131l\u0131r olsun diye, sat\u0131rlara b\u00f6l\u00fcnm\u00fc\u015f ve yorumlar eklenmi\u015ftir. Sizin \u00e7\u0131kt\u0131n\u0131z daha karma\u015f\u0131k g\u00f6r\u00fcnecektir ve yorumlar olmayacakt\u0131r.)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array(2) { \/\/ 2 elemanl\u0131 bir dizi geldi yani 2 adet ortam dosyas\u0131 geldi\n\n\t[2021]=> object(WP_Post)#4338 (24) \n            { \/\/ 1. elaman: 1. ortam dosyas\u0131 i\u00e7in olu\u015fturulmu\u015f bir PHP nesnesi \u015feklinde geldi\n\t\t[\"ID\"]=> int(2021) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(7) \"traktor\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(7) \"traktor\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(66) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/traktor.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\"\n\t    }\n\t\t\n\t[2020]=> object(WP_Post)#4336 (24) \n           { \/\/ 2. elaman: 2. ortam dosyas\u0131 i\u00e7in olu\u015fturulmu\u015f bir PHP nesnesi \u015feklinde geldi\n\t\t[\"ID\"]=> int(2020) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(6) \"sera-1\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(6) \"sera-1\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(65) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/sera-1.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\"\n\t    } \n\t}<\/code><\/pre>\n\n\n\n<p>Yukar\u0131da g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi, <code>$gelen_resimlerin_dizisi<\/code>, ihtiyac\u0131m\u0131z olan b\u00fct\u00fcn bilgileriyle birlikte, 1810 <em>ID<\/em> numaral\u0131 i\u00e7erik i\u00e7in y\u00fcklenen ortam dosyalar\u0131n\u0131 getirmi\u015ftir. \u00c7\u0131kt\u0131dan anl\u0131yoruz ki, i\u00e7erik, 2 tane resme sahiptir, bu y\u00fczden, <code>$gelen_resimlerin_dizisi<\/code> dizisi 2 elemanl\u0131 olarak gelmi\u015ftir.<\/p>\n\n\n\n<p>Peki, 1810 <em>ID<\/em> numaral\u0131 i\u00e7erik i\u00e7in y\u00fcklenmi\u015f bu resimleri, ekrana bast\u0131rmak istersek ne yapmal\u0131y\u0131z?<\/p>\n\n\n\n<p>Bu sorunun cevab\u0131, tamamen PHP bilgimizde yat\u0131yor. Elimizde bir dizi var, bu dizinin iki eleman\u0131 var, bu elemanlar\u0131n her biri bir PHP nesnesi format\u0131nda olu\u015fmu\u015f ve her bir nesne, url (<code>[\"guid\"]<\/code>) bilgisi de dahil, bir resim ile ilgili bilgiler i\u00e7eriyor. Yapmam\u0131z gereken tek \u015fey, bu bilgilerden ihtiyac\u0131m\u0131z olanlar\u0131 bir PHP d\u00f6ng\u00fcs\u00fc yard\u0131m\u0131 ile almakt\u0131r. A\u015fa\u011f\u0131da, bu resimleri ekrana bast\u0131rmak i\u00e7in kullanabilece\u011finiz bir kod \u00f6rne\u011fi verilmi\u015ftir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach( $gelen_resimlerin_dizisi as $resim ) {\n    echo '&lt;div class=\"resim parent-id-'.$resim->post_parent.' resim-id-'.$resim->ID.'\">\n            &lt;img width=\"400\" src=\"'.$resim->guid.'\" \/>\n          &lt;\/div>';\n}<\/code><\/pre>\n\n\n\n<p class=\"sc-dikkat\">Bazen, <em>ID<\/em> de\u011ferini verdi\u011finiz i\u00e7erikte, resim olmas\u0131na ra\u011fmen, <code>$gelen_resimlerin_dizisi<\/code> dizisi bo\u015f gelir veya resimlerin hepsini getirmez. Bunun sebebi, resimlerin, o i\u00e7eri\u011fe, y\u00fcklenerek de\u011fil, &#8220;<strong>Ortam k\u00fct\u00fcphanesi<\/strong>&#8220;nden se\u00e7ilerek eklenmi\u015f olmas\u0131d\u0131r. Ortam k\u00fct\u00fcphanesinden se\u00e7ilen resimler daha \u00f6nceden y\u00fcklenmi\u015f ve ebeveyn olarak da ba\u015fka i\u00e7eriklere atanm\u0131\u015ft\u0131r. Bu y\u00fczden, i\u00e7eri\u011fimize eklesek de i\u00e7eri\u011fimizin yavrusu olarak kabul edilmezler. \u00c7\u00fcnk\u00fc, bir i\u00e7erik olu\u015ftururken, &#8220;<strong>Y\u00fckle<\/strong>&#8221; butonu ile de\u011fil de, &#8220;<strong>Ortam k\u00fct\u00fcphanesi<\/strong>&#8220;nden se\u00e7ti\u011fimiz veya &#8220;<strong>Adresten ekle<\/strong>&#8220;di\u011fimiz resimlerin ebeveyni o i\u00e7erik olmaz ve <code>$gelen_resimlerin_dizisi<\/code> dizisiyle getirilemez. Bazen de, i\u00e7erik i\u00e7in y\u00fckledi\u011fimiz resimleri kald\u0131rmam\u0131za ra\u011fmen, kal\u0131c\u0131 olarak silmediysek tabi, <code>$gelen_resimlerin_dizisi<\/code> bu resimleri de getirir. \u00c7\u00fcnk\u00fc, <code>get_children()<\/code> fonksiyonu, yavru resimleri k\u00fct\u00fcphaneden bulur getirir, i\u00e7eri\u011fin g\u00fcncel halinden de\u011fil.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"248\" src=\"https:\/\/sitecenneti.com\/wordpress\/wp-content\/uploads\/sites\/15\/2019\/06\/wordpress-ordam-medya-dosyalari-3.png\" alt=\"\" class=\"wp-image-3066\" srcset=\"https:\/\/sitecenneti.com\/wordpress\/wp-content\/uploads\/sites\/15\/2019\/06\/wordpress-ordam-medya-dosyalari-3.png 755w, https:\/\/sitecenneti.com\/wordpress\/wp-content\/uploads\/sites\/15\/2019\/06\/wordpress-ordam-medya-dosyalari-3-300x99.png 300w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><figcaption>Bir \u0130\u00e7eri\u011fe Ortam Dosyas\u0131 (Resim) Ekleme Se\u00e7enekleri<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"dizinin_bicimi\">$dizinin_bicimi<\/span><\/h3>\n\n\n\n<p>(<em>Zorunlu de\u011fildir<\/em>) Bu arg\u00fcman, <code>get_children()<\/code> fonksiyonunun getirdi\u011fi i\u00e7erikleri bize nas\u0131l sunaca\u011f\u0131n\u0131 belirler. <code>get_children()<\/code> fonksiyonu, i\u00e7erikleri, her zaman bir dizi \u015feklinde getirir. <code>$dizinin_bicimi<\/code> parametresi bu kural\u0131 de\u011fi\u015ftiremez fakat dizinin bi\u00e7imini de\u011fi\u015ftirebilir. Bu arg\u00fcman \u00fc\u00e7 farkl\u0131 de\u011fer al\u0131r. Bu de\u011ferler \u015funlard\u0131r:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> <code>OBJECT<\/code> &#8211; <em>Varsay\u0131lan <\/em>: Dizinin her bir eleman\u0131 yani, gelen her bir i\u00e7erik bir PHP nesnesi (<em>object<\/em>) \u015feklinde gelir.<\/li><li> <code>ARRAY_A<\/code> : Dizinin her bir eleman\u0131 <code>'anahtari' =&gt; 'degeri'<\/code> \u015feklinde gelir.<\/li><li> <code>ARRAY_N<\/code> : Dizinin her bir eleman\u0131 <code>[0] =&gt; 'degeri'<\/code> \u015feklinde, numaral\u0131 gelir.<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span id=\"Ornek-1-2\">\u00d6rnek-1<\/span><\/h4>\n\n\n\n<p><code>$dizinin_bicimi<\/code> parametresi i\u00e7in, <code>OBJECT<\/code> de\u011ferinin kullan\u0131m\u0131na \u00f6rnek olarak a\u015fa\u011f\u0131daki kod verilmi\u015ftir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment', \/\/ sadece resimleri getir\n\t'post_parent' => 1810, \/\/ ID de\u011feri 1810 olan i\u00e7erik i\u00e7in y\u00fcklenen resimleri getir\n);\n\n\/\/ OBJECT de\u011feri, varsay\u0131lan ve iste\u011fe ba\u011fl\u0131 oldu\u011fu i\u00e7in, a\u015fa\u011f\u0131daki iki dizi birbiriyle ayn\u0131d\u0131r.\n$gelen_resimlerin_dizisi = get_children($argumanlar, OBJECT);\n\/\/ veya\n$gelen_resimlerin_dizisi = get_children($argumanlar);<\/code><\/pre>\n\n\n\n<p><code>OBJECT<\/code> parametresi ile olu\u015fturulan <code>$gelen_resimlerin_dizisi<\/code> dizisi, \u015f\u00f6yle bir dizi olarak gelir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array(2) { \/\/ 2 elemanl\u0131 bir dizi geldi yani 2 adet ortam dosyas\u0131 geldi\n\n\t[2021]=> object(WP_Post)#4338 (24) { \/\/ 1. elaman: 1. ortam dosyas\u0131 i\u00e7in olu\u015fturulmu\u015f bir PHP nesnesi \u015feklinde geldi\n\t\t[\"ID\"]=> int(2021) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(7) \"traktor\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(7) \"traktor\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(66) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/traktor.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\"\n\t\t}\n\t\t\n\t[2020]=> object(WP_Post)#4336 (24) { \/\/ 2. elaman: 2. ortam dosyas\u0131 i\u00e7in olu\u015fturulmu\u015f bir PHP nesnesi \u015feklinde geldi\n\t\t[\"ID\"]=> int(2020) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(6) \"sera-1\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(6) \"sera-1\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(65) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/sera-1.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\"\n\t\t} \n\t}<\/code><\/pre>\n\n\n\n<p>Gelen resimleri, \u015fablon dosyalar\u0131m\u0131zda kullanmak i\u00e7in, fikir vermesi a\u00e7\u0131s\u0131ndan, \u015fu kodu kullanabiliriz:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment',\n\t'post_parent' => 1810,\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar);\n\t\t\t\t\nforeach( $gelen_resimlerin_dizisi as $resim ) {\n    echo '&lt;div class=\"resim parent-id-'.$resim->post_parent.' resim-id-'.$resim->ID.'\">\n            &lt;img width=\"400\" src=\"'.$resim->guid.'\" \/>\n          &lt;\/div>';\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span id=\"Ornek-2\">\u00d6rnek-2<\/span><\/h4>\n\n\n\n<p><code>$dizinin_bicimi<\/code> parametresi i\u00e7in, <code>ARRAY_A<\/code> de\u011ferinin kullan\u0131m\u0131na \u00f6rnek olarak a\u015fa\u011f\u0131daki kod verilmi\u015ftir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment', \/\/ sadece resimleri getir\n\t'post_parent' => 1810, \/\/ ID de\u011feri 1810 olan i\u00e7erik i\u00e7in y\u00fcklenen resimleri getir\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar, ARRAY_A);<\/code><\/pre>\n\n\n\n<p><code>ARRAY_A<\/code> parametresi ile olu\u015fturulan <code>$gelen_resimlerin_dizisi<\/code> dizisi, \u015f\u00f6yle bir dizi olarak gelir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array(2) { \n\t[2021]=> array(24) \n\t{ \n\t\t[\"ID\"]=> int(2021) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(7) \"traktor\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(7) \"traktor\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(66) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/traktor.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\" \n\t} \n\t[2020]=> array(24) \n\t{ \n\t\t[\"ID\"]=> int(2020) \n\t\t[\"post_author\"]=> string(1) \"1\" \n\t\t[\"post_date\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_date_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content\"]=> string(0) \"\" \n\t\t[\"post_title\"]=> string(6) \"sera-1\" \n\t\t[\"post_excerpt\"]=> string(0) \"\" \n\t\t[\"post_status\"]=> string(7) \"inherit\" \n\t\t[\"comment_status\"]=> string(4) \"open\" \n\t\t[\"ping_status\"]=> string(6) \"closed\" \n\t\t[\"post_password\"]=> string(0) \"\" \n\t\t[\"post_name\"]=> string(6) \"sera-1\" \n\t\t[\"to_ping\"]=> string(0) \"\" \n\t\t[\"pinged\"]=> string(0) \"\" \n\t\t[\"post_modified\"]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[\"post_modified_gmt\"]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[\"post_content_filtered\"]=> string(0) \"\" \n\t\t[\"post_parent\"]=> int(1810) \n\t\t[\"guid\"]=> string(65) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/sera-1.jpg\" \n\t\t[\"menu_order\"]=> int(0) \n\t\t[\"post_type\"]=> string(10) \"attachment\" \n\t\t[\"post_mime_type\"]=> string(10) \"image\/jpeg\" \n\t\t[\"comment_count\"]=> string(1) \"0\" \n\t\t[\"filter\"]=> string(3) \"raw\" \n\t} \n}<\/code><\/pre>\n\n\n\n<p>Gelen resimleri, \u015fablon dosyalar\u0131m\u0131zda kullanmak i\u00e7in, fikir vermesi a\u00e7\u0131s\u0131ndan, \u015fu kodu kullanabiliriz:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment',\n\t'post_parent' => 1810,\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar, ARRAY_A);\n\t\t\t\t\nforeach( $gelen_resimlerin_dizisi as $resim ) {\n    echo '&lt;div class=\"resim parent-id-'.$resim['post_parent'].' resim-id-'.$resim['ID'].'\">\n            &lt;img width=\"400\" src=\"'.$resim['guid'].'\" \/>\n          &lt;\/div>';\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span id=\"Ornek-3\">\u00d6rnek-3<\/span><\/h4>\n\n\n\n<p><code>$dizinin_bicimi<\/code> parametresi i\u00e7in, <code>ARRAY_N<\/code> de\u011ferinin kullan\u0131m\u0131na \u00f6rnek olarak a\u015fa\u011f\u0131daki kod verilmi\u015ftir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment', \/\/ sadece resimleri getir\n\t'post_parent' => 1810, \/\/ ID de\u011feri 1810 olan i\u00e7erik i\u00e7in y\u00fcklenen resimleri getir\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar, ARRAY_N);<\/code><\/pre>\n\n\n\n<p><code>ARRAY_N<\/code> parametresi ile olu\u015fturulan <code>$gelen_resimlerin_dizisi<\/code> dizisi, \u015f\u00f6yle bir dizi olarak gelir:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>array(2) {\n\t\n\t[2021]=> array(24) \n\t{ \n\t\t[0]=> int(2021) \n\t\t[1]=> string(1) \"1\" \n\t\t[2]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[3]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[4]=> string(0) \"\" \n\t\t[5]=> string(7) \"traktor\" \n\t\t[6]=> string(0) \"\" \n\t\t[7]=> string(7) \"inherit\" \n\t\t[8]=> string(4) \"open\" \n\t\t[9]=> string(6) \"closed\" \n\t\t[10]=> string(0) \"\" \n\t\t[11]=> string(7) \"traktor\" \n\t\t[12]=> string(0) \"\" \n\t\t[13]=> string(0) \"\" \n\t\t[14]=> string(19) \"2019-06-16 13:16:03\" \n\t\t[15]=> string(19) \"2019-06-16 10:16:03\" \n\t\t[16]=> string(0) \"\" \n\t\t[17]=> int(1810) \n\t\t[18]=> string(66) \"https:\/\/sitecenneti.com\/wp-content\/uploads\/2019\/06\/traktor.jpg\" \n\t\t[19]=> int(0) \n\t\t[20]=> string(10) \"attachment\" \n\t\t[21]=> string(10) \"image\/jpeg\" \n\t\t[22]=> string(1) \"0\" \n\t\t[23]=> string(3) \"raw\" \n\t} \n\t\n\t[2020]=> array(24) \n\t{ \n\t\t[0]=> int(2020) \n\t\t[1]=> string(1) \"1\" \n\t\t[2]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[3]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[4]=> string(0) \"\" \n\t\t[5]=> string(6) \"sera-1\" \n\t\t[6]=> string(0) \"\" \n\t\t[7]=> string(7) \"inherit\" \n\t\t[8]=> string(4) \"open\" \n\t\t[9]=> string(6) \"closed\" \n\t\t[10]=> string(0) \"\" \n\t\t[11]=> string(6) \"sera-1\" \n\t\t[12]=> string(0) \"\" \n\t\t[13]=> string(0) \"\" \n\t\t[14]=> string(19) \"2019-06-16 13:16:02\" \n\t\t[15]=> string(19) \"2019-06-16 10:16:02\" \n\t\t[16]=> string(0) \"\" \n\t\t[17]=> int(1810) \n\t\t[18]=> string(65) \"http:\/\/localhost\/benimsitem\/wp-content\/uploads\/2019\/06\/sera-1.jpg\" \n\t\t[19]=> int(0) \n\t\t[20]=> string(10) \"attachment\" \n\t\t[21]=> string(10) \"image\/jpeg\" \n\t\t[22]=> string(1) \"0\" \n\t\t[23]=> string(3) \"raw\" \n\t} \n}<\/code><\/pre>\n\n\n\n<p>Gelen resimleri, \u015fablon dosyalar\u0131m\u0131zda kullanmak i\u00e7in, fikir vermesi a\u00e7\u0131s\u0131ndan, \u015fu kodu kullanabiliriz:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$argumanlar = array(\n\t'post_type' => 'attachment',\n\t'post_parent' => 1810,\n);\n\n$gelen_resimlerin_dizisi = get_children($argumanlar, ARRAY_N);\n\t\t\t\t\nforeach( $gelen_resimlerin_dizisi as $resim ) {\n    echo '&lt;div class=\"resim parent-id-'.$resim[17].' resim-id-'.$resim[0].'\">\n            &lt;img width=\"400\" src=\"'.$resim[18].'\" \/>\n          &lt;\/div>';\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Dondurdugu_Sonuc\">D\u00f6nd\u00fcrd\u00fc\u011f\u00fc Sonu\u00e7:<\/span><\/h2>\n\n\n\n<p><code>Get_children()<\/code> fonksiyonu, bir dizi d\u00f6nd\u00fcr\u00fcr. Dizinin bi\u00e7imi, ikinci parametresine ba\u011fl\u0131d\u0131r.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Kaynak_Kodu\">Kaynak Kodu:<\/span><\/h2>\n\n\n\n<p>Dizini: <strong>wp-includes\/post.php<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function get_children( $args = '', $output = OBJECT ) {\n    $kids = array();\n    if ( empty( $args ) ) {\n        if ( isset( $GLOBALS['post'] ) ) {\n            $args = array( 'post_parent' => (int) $GLOBALS['post']->post_parent );\n        } else {\n            return $kids;\n        }\n    } elseif ( is_object( $args ) ) {\n        $args = array( 'post_parent' => (int) $args->post_parent );\n    } elseif ( is_numeric( $args ) ) {\n        $args = array( 'post_parent' => (int) $args );\n    }\n \n    $defaults = array(\n        'numberposts' => -1,\n        'post_type'   => 'any',\n        'post_status' => 'any',\n        'post_parent' => 0,\n    );\n \n    $r = wp_parse_args( $args, $defaults );\n \n    $children = get_posts( $r );\n \n    if ( ! $children ) {\n        return $kids;\n    }\n \n    if ( ! empty( $r['fields'] ) ) {\n        return $children;\n    }\n \n    update_post_cache( $children );\n \n    foreach ( $children as $key => $child ) {\n        $kids[ $child->ID ] = $children[ $key ];\n    }\n \n    if ( $output == OBJECT ) {\n        return $kids;\n    } elseif ( $output == ARRAY_A ) {\n        $weeuns = array();\n        foreach ( (array) $kids as $kid ) {\n            $weeuns[ $kid->ID ] = get_object_vars( $kids[ $kid->ID ] );\n        }\n        return $weeuns;\n    } elseif ( $output == ARRAY_N ) {\n        $babes = array();\n        foreach ( (array) $kids as $kid ) {\n            $babes[ $kid->ID ] = array_values( get_object_vars( $kids[ $kid->ID ] ) );\n        }\n        return $babes;\n    } else {\n        return $kids;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>WordPress&#8217;in \u00fcretti\u011fi bir fonksiyon olan, get_children() fonksiyonu, b\u00fct\u00fcn y\u00f6nleriyle ve \u00f6rnekler verilerek anlat\u0131lm\u0131\u015ft\u0131r.<\/p>\n","protected":false},"author":1,"featured_media":3103,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[137,138,136],"class_list":["post-3324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-fonksiyonlari","tag-get-children","tag-get_children","tag-wordpress-get_children"],"_links":{"self":[{"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/posts\/3324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3324"}],"version-history":[{"count":0,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/posts\/3324\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/media\/3103"}],"wp:attachment":[{"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sitecenneti.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}