{"id":91,"date":"2018-02-17T23:41:00","date_gmt":"2018-02-17T22:41:00","guid":{"rendered":"https:\/\/schoppe.it\/wiki\/?p=91"},"modified":"2024-09-03T08:51:24","modified_gmt":"2024-09-03T06:51:24","slug":"beitraege-anzeigen-lassen-mit-wp_query","status":"publish","type":"post","link":"https:\/\/schoppe.it\/wiki\/beitraege-anzeigen-lassen-mit-wp_query\/","title":{"rendered":"Beitr\u00e4ge anzeigen lassen mit wp_query"},"content":{"rendered":"\n<p>Zur Anzeige der aktuellsten Beitr\u00e4ge auf einer Seite wird der folgenden Code in eine Seiten-Template-PHP eingef\u00fcgt.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; first-line: 1; title: ; notranslate\" title=\"\">\n&lt;div id=&quot;Start_Beitraege&quot;&gt;\n\t&lt;h2&gt;Letzte Beitr\u00e4ge&lt;\/h2&gt;\n\t&lt;ul&gt;\n\t\t&lt;?php \n\t\t\/\/ the query\n\t\t\n\t\t$args = array(\n\t\t&#039;post_type&#039; =&gt; &#039;post&#039;,\n\t\t&#039;showposts&#039; =&gt; &#039;12&#039;,\n\t\t&#039;post_status&#039; =&gt; &#039;publish&#039;\n\t\t);\n\t\t\n\t\t$the_query = new WP_Query( $args ); ?&gt;\n\n\t\t&lt;?php if ( $the_query-&gt;have_posts() ) : ?&gt;\n\n\t\t\t&lt;!-- pagination here --&gt;\n\n\t\t\t&lt;!-- the loop --&gt;\n\t\t\t&lt;?php while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); ?&gt;\n\t\t\t\t&lt;li&gt;\n\t\t\t\t\t&lt;a href=&quot;&lt;?php echo the_permalink( $post-&gt;ID ); ?&gt;&quot;&gt;\n\t\t\t\t\t&lt;?php the_title(); ?&gt;\n\t\t\t\t\t&lt;\/a&gt;\n\t\t\t\t\t&lt;div id=&quot;Start_Beitraege_Meta&quot;&gt;\n\t\t\t\t\tKategorie: &lt;?php echo get_the_category_list( __( &#039;, &#039;, &#039;twentysixteen&#039; ) ); ?&gt; Datum: &lt;?php echo get_the_date(); ?&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t&lt;\/li&gt;\n\t\t\t&lt;?php endwhile; ?&gt;\n\t\t\t&lt;!-- end of the loop --&gt;\n\n\t\t\t&lt;!-- pagination here --&gt;\n\n\t\t\t&lt;?php wp_reset_postdata(); ?&gt;\n\n\t\t&lt;?php else : ?&gt;\n\t\t\t&lt;p&gt;&lt;?php esc_html_e( &#039;Sorry, no posts matched your criteria.&#039; ); ?&gt;&lt;\/p&gt;\n\t\t&lt;?php endif; ?&gt;\t\t\t\t\t\n\t&lt;\/ul&gt;\n&lt;\/div&gt;&lt;!-- Ende: Start_Beitraege --&gt;\n<\/pre><\/div>\n\n\n<p>Das Beispiel generiert eine Liste der letzten 12 Beitr\u00e4ge, die den Status <em>publish<\/em> haben<strong>.<\/strong><\/p>\n\n\n\n<p>Des Weiteren werden die Kategorien (<em>get_the_category_list<\/em>) und das Beitragsdatum (<em>get_the_date<\/em>) ausgegeben.<\/p>\n\n\n\n<p>Der Titel wird als html-Verweis auf <em>the_permalink<\/em> dargestellt.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;a href=&quot;&lt;?php echo &lt;strong&gt;the_permalink&lt;\/strong&gt;( $post-&gt;ID ); ?&gt;&quot;&gt; &lt;?php &lt;strong&gt;the_title&lt;\/strong&gt;(); ?&gt; &lt;\/a&gt;\n<\/pre><\/div>\n\n\n<p>Im WordPress Codex werden alle verf\u00fcgbaren Parameter beschrieben.<\/p>\n\n\n\n<p><a href=\"https:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\">https:\/\/codex.wordpress.org\/Class_Reference\/WP_Query<\/a><\/p>\n\n\n\n<p>Selektionen (und Sortierungen) sind m\u00f6glich nach:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Author<\/li><li>Category<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&#039;cat&#039; =&gt; &#039;1,2,3,4&#039;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\"><li>Tag<\/li><li>Taxonomy<\/li><li>Search Keywords<\/li><li>Post and Page Parameters<\/li><li>Password Parameters<\/li><li>Post Type<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&#039;post_type&#039; =&gt; array( &#039;post&#039;, &#039;page&#039;, &#039;&lt;em&gt;my_post_type&lt;\/em&gt;&#039; )\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\"><li>Status<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&#039;post_status&#039; =&gt; array( &#039;pending&#039;, &#039;draft&#039;, &#039;future&#039;, &#039;publish&#039; )\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\"><li>Comments<\/li><li>Pagination<\/li><li>Order und Orderby<\/li><li>Date<\/li><li>Custom Fields<\/li><li>Permissions<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Zur Anzeige der aktuellsten Beitr\u00e4ge auf einer Seite wird der folgenden Code in eine Seiten-Template-PHP eingef\u00fcgt. Das Beispiel generiert eine Liste der letzten 12 Beitr\u00e4ge, die den Status publish haben. Des Weiteren werden die Kategorien (get_the_category_list) und das Beitragsdatum (get_the_date) ausgegeben. Der Titel wird als html-Verweis auf the_permalink dargestellt. Im WordPress Codex werden alle verf\u00fcgbaren&hellip; <a class=\"more-link\" href=\"https:\/\/schoppe.it\/wiki\/beitraege-anzeigen-lassen-mit-wp_query\/\"><span class=\"screen-reader-text\">Beitr\u00e4ge anzeigen lassen mit wp_query<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"powershell":[],"wordpress":[36,37,38,39,40,41],"exchange":[],"linux":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-wordpress","wordpress-get_the_category_list","wordpress-get_the_date","wordpress-the_permalink","wordpress-the_title","wordpress-wp_query","wordpress-wp_reset_postdata","entry"],"_links":{"self":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":5,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/91\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/tags?post=91"},{"taxonomy":"powershell","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/powershell?post=91"},{"taxonomy":"wordpress","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/wordpress?post=91"},{"taxonomy":"exchange","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/exchange?post=91"},{"taxonomy":"linux","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/linux?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}