{"id":232726,"date":"2023-01-28T18:15:00","date_gmt":"2023-01-28T15:15:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232726"},"modified":"2023-01-28T18:16:32","modified_gmt":"2023-01-28T15:16:32","slug":"hur-visar-jag-inlaegg-av-historisk-idag-i-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/sv\/hur-visar-jag-inlaegg-av-historisk-idag-i-wordpress\/","title":{"rendered":"Hur visar jag inl\u00e4gg av historisk &#8221;Idag&#8221; i WordPress?"},"content":{"rendered":"<p>Du kan visa &quot;Relaterade&quot; inl\u00e4gg (med taggar, kategorier eller andra nyckelord) f\u00f6r att locka fler sidvisningar. Alternativt kan du visa historiska inl\u00e4gg fr\u00e5n &quot;Idag&quot; i det f\u00f6rflutna i slutet av inl\u00e4ggets inneh\u00e5ll. Kopiera f\u00f6ljande PHP-kod och l\u00e4gg den i slutet av wordpress funktionsmallen <strong>functions.php<\/strong>, helst med <a href=\"https:\/\/wordpress.mediadoma.com\/sv\/wordpress-barntema-det-enda-du-behoever-veta\/\" title=\"barntema\">barntema<\/a>.<\/p>\n<pre><code>function today_in_histroy(){\n\u00a0 \u00a0 $today = getdate();\n\u00a0 \u00a0 $args = array(\n\u00a0 \u00a0 \u00a0 \u00a0 'date_query' =&gt; array(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 array(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'year' \u00a0 \u00a0 \u00a0=&gt; $today['year'],\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'compare' \u00a0 =&gt; '!=',\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 array(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'month' =&gt; $today['mon'],\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 'day' \u00a0 =&gt; $today['mday'],\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ),\n\u00a0 \u00a0 \u00a0 \u00a0 ),\n\u00a0 \u00a0 );\n\u00a0 \u00a0 $postlist = get_posts($args);\n\u00a0 \u00a0 $html = '&lt;h3 class=\"tih-title\"&gt;Posts of Historic Today&lt;\/h3&gt;&lt;ul class=\"tih-title-list\"&gt;';\n\u00a0 \u00a0 if(!empty($postlist)){\n\u00a0 \u00a0 \u00a0 \u00a0 foreach ($postlist as $key =&gt; $post) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $html .= '&lt;li class=\"tih-title-item\"&gt;&lt;a href=\"'. get_permalink($post-&gt;ID). '\" title=\"'. $post-&gt;post_title. '\"&gt;'. $post-&gt;post_title. '&lt;\/a&gt;&lt;\/li&gt;';\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 $html .= '&lt;\/ul&gt;';\n\u00a0 \u00a0 \u00a0 \u00a0 return $html;\n\u00a0 \u00a0 }\n\u00a0 \u00a0 return \"\";\n}\n\u00a0\nfunction add_today_in_histroy($content){\n\u00a0 \u00a0 global $post;\n\u00a0 \u00a0 return \u00a0$content. today_in_histroy(); \n}\nadd_filter('the_content','add_today_in_histroy');<\/code><\/pre>\n<p>Tanken \u00e4r att ha en fr\u00e5ga som s\u00f6ker efter inl\u00e4ggen och anv\u00e4nda <strong>add_filter<\/strong> f\u00f6r att l\u00e4gga till <strong>the_content<\/strong>.<\/p>\n<p>wordpress<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Inspelningsk\u00e4lla:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hur visar jag inl\u00e4gg om historiska &#8221;Idag&#8221; i WordPress?<\/p>\n","protected":false},"author":1,"featured_media":221210,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[838,848,999,901,922,807,868],"tags":[1173],"class_list":["post-232726","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guide-foer-nyboerjare","category-handledningar","category-innehallsmarknadsforing","category-koda","category-oevrig","category-php-9","category-wordpress-9","tag-affiai-sv"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/232726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/comments?post=232726"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/232726\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media\/221210"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media?parent=232726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/categories?post=232726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/tags?post=232726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}