{"id":3739,"date":"2011-09-16T16:45:19","date_gmt":"2011-09-16T14:45:19","guid":{"rendered":"http:\/\/xlogic.org\/blog\/?p=3739"},"modified":"2020-04-25T16:04:04","modified_gmt":"2020-04-25T14:04:04","slug":"wordpress-codice-php","status":"publish","type":"post","link":"https:\/\/xlogic.org\/blog\/wordpress-codice-php.html\/","title":{"rendered":"WordPress &#8211; Codice PHP"},"content":{"rendered":"<p>WordPress \u00e8 il CMS pi\u00f9 usato al mondo ed \u00e8 anche il pi\u00f9 completo e flessibile, infatti\u00a0senza conoscere il linguaggio PHP \u00e8 possibile tramite l&#8217;inserimento di codici visualizzare dei contenuti dinamici.<\/p>\n<p>In questa articolo vi mostriamo il codice PHP da inserire nel template per visualizzare determinate sezioni.<\/p>\n<p><strong>Visualizzare le Categorie<\/strong><\/p>\n<pre>&lt;h2&gt;Categories&lt;\/h2&gt;\r\n&lt;ul&gt;\r\n&lt;?php wp_list_cats('sort_column=name'); ?&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare le Categorie in un Men\u00f9 a Tendina<\/strong><\/p>\n<pre>&lt;form action=\"&lt;?php bloginfo('url'); ?&gt;\/\" method=\"get\"&gt;\r\n&lt;?php\r\n$select = wp_dropdown_categories('show_option_none=Select category&amp;show_count=1&amp;orderby=name&amp;echo=0');\r\n$select = preg_replace(\"#&lt;select([^&gt;]*)&gt;#\", \"&lt;select$1 onchange='return this.form.submit()'&gt;\", $select);\r\necho $select; ?&gt; &lt;noscript&gt;&lt;input type=\"submit\" value=\"View\" \/&gt;&lt;\/noscript&gt;\r\n&lt;\/form&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare i Post Recenti<\/strong><\/p>\n<pre>&lt;?php query_posts('showposts=5'); ?&gt;\r\n&lt;ul&gt;\r\n&lt;?php while (have_posts()) : the_post(); ?&gt;\r\n&lt;li&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;?php endwhile;?&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare i Commenti recenti<\/strong><\/p>\n<pre>&lt;?php\r\nglobal $wpdb;\r\n$sql = \"SELECT DISTINCT ID, post_title, post_password, comment_ID,\r\ncomment_post_ID, comment_author, comment_date_gmt, comment_approved,\r\ncomment_type,comment_author_url,\r\nSUBSTRING(comment_content,1,30) AS com_excerpt\r\nFROM $wpdb-&gt;comments\r\nLEFT OUTER JOIN $wpdb-&gt;posts ON ($wpdb-&gt;comments.comment_post_ID =\r\n$wpdb-&gt;posts.ID)\r\nWHERE comment_approved = '1' AND comment_type = '' AND\r\npost_password = ''\r\nORDER BY comment_date_gmt DESC\r\nLIMIT 10\";\r\n$comments = $wpdb-&gt;get_results($sql);\r\n$output = $pre_HTML;\r\n$output .= \"\\n&lt;ul&gt;\";\r\nforeach ($comments as $comment) {\r\n$output .= \"\\n&lt;li&gt;\".strip_tags($comment-&gt;comment_author)\r\n.\":\" . \"&lt;a href=\\\"\" . get_permalink($comment-&gt;ID) .\r\n\"#comment-\" . $comment-&gt;comment_ID . \"\\\" title=\\\"on \" .\r\n$comment-&gt;post_title . \"\\\"&gt;\" . strip_tags($comment-&gt;com_excerpt)\r\n.\"&lt;\/a&gt;&lt;\/li&gt;\";\r\n}\r\n$output .= \"\\n&lt;\/ul&gt;\";\r\n$output .= $post_HTML;\r\necho $output;?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare gli Archivi<\/strong><\/p>\n<pre>&lt;h2&gt;Archives&lt;\/h2&gt;\r\n&lt;ul&gt;\r\n&lt;?php wp_get_archives('type=monthly'); ?&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare i Gravatars<\/strong><\/p>\n<pre>&lt;?php if(function_exists(\u2019get_avatar\u2019)){ echo get_avatar($comment, \u201850?);} ?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare i Tag dei Post<\/strong><\/p>\n<pre>&lt;?php the_tags(); ?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Visualizzare i Tag Cloud<\/strong><\/p>\n<pre>&lt;?php wp_tag_cloud('smallest=8&amp;largest=36&amp;number=10'); ?&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Tutti i Codici:<\/strong><\/p>\n<p>Visualizzare il titolo della pagina o articolo :\u00a0<span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_title() ?&gt;<\/span><\/p>\n<p>Visualizzare il contenuto della pagina o articolo :\u00a0<span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_content() ?&gt;<\/span><\/p>\n<p>Visualizzare il sommario dell&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_excerpt() ?&gt;<\/span><\/p>\n<p>Visualizzare il tempo di pubblicazione : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_time() ?&gt;<\/span><\/p>\n<p>Visualizzare la data di pubblicazione : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_date() ?&gt;<\/span><\/p>\n<p>Visualizzare l&#8217;url nell&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_permalink() ?&gt;<\/span><\/p>\n<p>Visualizzare il link alla categoria dell&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_category() ?&gt;<\/span><\/p>\n<p>Visualizzare l&#8217;autore dell&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_author() ?&gt;<\/span><\/p>\n<p>Visualizzare l&#8217;id dell&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_ID() ?&gt;<\/span><\/p>\n<p>Visualizzare tutte le pagine : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_list_pages() ?&gt;<\/span><\/p>\n<p>Visualizzare i tag : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_tag_cloud() ?&gt;<\/span><\/p>\n<p>Visualizzare le categorie : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_list_cats() ?&gt;<\/span><\/p>\n<p>Visualizzare il calendario : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php get_calendar() ?&gt;<\/span><\/p>\n<p>Visualizzare gli archivi : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_get_archives() ?&gt;<\/span><\/p>\n<p>Visualizzare i link pagina successiva e precedente : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php posts_nav_link() ?&gt;<\/span><\/p>\n<p>Visualizzare i link agli articoli pi\u00f9 recenti : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php next_post_link() ?&gt;<\/span><\/p>\n<p>Visualizzare i link agli articoli meno recenti \u00a0: <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php previous_post_link() ?&gt;<\/span><\/p>\n<p>Visualizzare il link per editare l&#8217;articolo : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? edit_post_link(__(&#8216;edit post&#8217;)) ?&gt;<\/span><\/p>\n<p>Valore per il modulo di ricerca : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php the_search_query() ?&gt;<\/span><\/p>\n<p>Visualizzare il link per la registrazione : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_register() ?&gt;<\/span><\/p>\n<p>Visualizzare il link login e logout : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_loginout() ?&gt;<\/span><\/p>\n<p>Visualizzare il contenuto per la sidebar : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php wp_meta() ?&gt;<\/span><\/p>\n<p>Visualizzare il tempo di caricamento della pagina : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php timer_stop(1) ?&gt;<\/span><\/p>\n<p>Visualizzare i link da blogroll : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php get_links_list() ?&gt;<\/span><\/p>\n<p>Visualizzare i links ai commenti inseriti : <span class=\"Apple-style-span\" style=\"font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">&lt;? php comments_popup_link() ?&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Alla Prossima.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress \u00e8 il CMS pi\u00f9 usato al mondo ed \u00e8 anche il pi\u00f9 completo e flessibile, infatti\u00a0senza conoscere il linguaggio PHP \u00e8 possibile tramite l&#8217;inserimento di codici visualizzare dei contenuti dinamici. In questa articolo vi mostriamo il codice PHP da inserire nel template per visualizzare determinate sezioni. Visualizzare le Categorie &lt;h2&gt;Categories&lt;\/h2&gt; &lt;ul&gt; &lt;?php wp_list_cats(&#8216;sort_column=name&#8217;); ?&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":"","footnotes":""},"categories":[4,1401],"tags":[442,28,441],"class_list":["post-3739","post","type-post","status-publish","format-standard","hentry","category-guide","category-wordpress","tag-codice-wordpress","tag-wordpress","tag-wordpress-code"],"modified_by":"Team tecnico Xlogic","_links":{"self":[{"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/posts\/3739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/comments?post=3739"}],"version-history":[{"count":0,"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/posts\/3739\/revisions"}],"wp:attachment":[{"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/media?parent=3739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/categories?post=3739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlogic.org\/blog\/wp-json\/wp\/v2\/tags?post=3739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}