{"id":779,"date":"2007-11-01T22:34:25","date_gmt":"2007-11-01T20:34:25","guid":{"rendered":"http:\/\/iko.drundrun.org\/blog\/?p=779"},"modified":"2007-11-07T01:27:46","modified_gmt":"2007-11-06T23:27:46","slug":"how-to-create-dynamic-page-in-wordpress","status":"publish","type":"post","link":"https:\/\/iko.drundrun.org\/blog\/?p=779","title":{"rendered":"How to create dynamic page in WordPress"},"content":{"rendered":"<p>I&#8217;ve searched for such how-to, but I didn&#8217;t find something exactly like this, so I decided to try by myself and I did it \ud83d\ude42 The goal was to make  page (<a href=\"http:\/\/codex.wordpress.org\/Pages\">page as meaning of wordpress<\/a>), which displays dynamic content everytime it&#8217;s loaded. Dynamic content is simply RSS feed. To parse content I needed PHP and start to find way to make WordPress to manage data from database as code. First it&#8217;s sound like impossible thing, but of course, there are not impossible things \ud83d\ude42 The solution, that I found, is <a href=\"http:\/\/bluesome.net\/post\/2005\/08\/18\/50\/\">Exec-PHP<\/a> plugin for WordPress. It does exactly this &#8211; allows to insert PHP code in wordpress post or page.<\/p>\n<p>Second hard thing was how to write PHP code in WordPress editor, because everytime when I pressed Save (or Publish) WordPress messed up everything. I tried tips on <a href=\"http:\/\/bluesome.net\/post\/2005\/08\/18\/50\/\">Exec-PHP site<\/a>, but I didn&#8217;t success. The final solution was to edit directly database. So I created a blank page with editor, and than inserted content (with PHP code) with PhpMyAdmin \ud83d\ude42 Now everything looks like almost as I expected.<\/p>\n<p>Now I have two dynamic pages &#8211; <a href=\"http:\/\/iko.drundrun.org\/blog\/?page_id=774\">my recent tracks from last.fm<\/a> and  <a href=\"http:\/\/iko.drundrun.org\/blog\/?page_id=777\">my recent visited events<\/a> (from <a href=\"http:\/\/scenata.com\">scenata.com<\/a>). If you want some similar functionality for your blog just do these three steps:<\/p>\n<ol>\n<li>download and install Exec-PHP plug in<\/li>\n<li>create a page (or post) with WodPress editor<\/li>\n<li>Edit page (or post) with PhpMyAdmin (or whatever you want) and replace field <em>post_content<\/em> with something like this (for last.fm recent tracks):<\/li>\n<\/ol>\n<blockquote><p>&lt;h3&gt;ik0&#8217;s Recently Played Tracks&lt;\/h3&gt;<br \/>\n&lt;h4&gt;<br \/>\n&lt;?php<br \/>\ninclude_once(ABSPATH . WPINC . &#8216;\/rss.php&#8217;);<br \/>\n$rss = fetch_rss(&#8216;http:\/\/ws.audioscrobbler.com\/1.0\/user\/ik0\/recenttracks.rss&#8217;);<br \/>\n$maxitems = 10;<br \/>\n$items = array_slice($rss-&gt;items, 0, $maxitems);<br \/>\n?&gt;<\/p>\n<p>&lt;?php if (empty($items)) echo &#8216;No items&#8217;;<br \/>\nelse<br \/>\nforeach ( $items as $item ) : ?&gt;<br \/>\n&lt;a href=&#8221;&lt;?php echo $item[&#8216;link&#8217;]; ?&gt;&#8221;&gt;<br \/>\n&lt;?php echo $item[&#8216;title&#8217;]; ?&gt;<br \/>\n&lt;\/a&gt;<br \/>\n&lt;?php endforeach; ?&gt;<br \/>\n&lt;\/h4&gt;<\/p><\/blockquote>\n<p>That&#8217;s it \ud83d\ude42 If you tell me some easier way, I&#8217;ll be glad.<\/p>\n<p>p.s. Yes, it&#8217;s ugly, but it can be done more beautiful. By now it&#8217;s just works !<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-official sd-sharing\"><h3 class=\"sd-title\">\u0421\u043f\u043e\u0434\u0435\u043b\u0435\u0442\u0435 \u0442\u043e\u0432\u0430:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><div class=\"fb-share-button\" data-href=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-layout=\"button_count\"><\/div><\/li><li class=\"share-twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-text=\"How to create dynamic page in WordPress\"  >Tweet<\/a><\/li><li class=\"share-pocket\"><div class=\"pocket_button\"><a href=\"https:\/\/getpocket.com\/save\" class=\"pocket-btn\" data-lang=\"en\" data-save-url=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-pocket-count=\"horizontal\" >Pocket<\/a><\/div><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve searched for such how-to, but I didn&#8217;t find something exactly like this, so I decided to try by myself and I did it \ud83d\ude42 The goal was to make page (page as meaning of wordpress), which displays dynamic content everytime it&#8217;s loaded. Dynamic content is simply RSS feed. To parse content I needed PHP &hellip; <a href=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to create dynamic page in WordPress<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-official sd-sharing\"><h3 class=\"sd-title\">\u0421\u043f\u043e\u0434\u0435\u043b\u0435\u0442\u0435 \u0442\u043e\u0432\u0430:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><div class=\"fb-share-button\" data-href=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-layout=\"button_count\"><\/div><\/li><li class=\"share-twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-text=\"How to create dynamic page in WordPress\"  >Tweet<\/a><\/li><li class=\"share-pocket\"><div class=\"pocket_button\"><a href=\"https:\/\/getpocket.com\/save\" class=\"pocket-btn\" data-lang=\"en\" data-save-url=\"https:\/\/iko.drundrun.org\/blog\/?p=779\" data-pocket-count=\"horizontal\" >Pocket<\/a><\/div><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[8,16],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p2r9Xz-cz","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/779"}],"collection":[{"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=779"}],"version-history":[{"count":0,"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions"}],"wp:attachment":[{"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iko.drundrun.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}