{"id":371916,"date":"2023-05-12T19:31:00","date_gmt":"2023-05-12T16:31:00","guid":{"rendered":"https:\/\/themewp.inform.click\/?p=371916"},"modified":"2022-10-14T06:26:24","modified_gmt":"2022-10-14T03:26:24","slug":"korosta-kuuman-aiheen-viesti-joka-sisaltaa-yli-5-kommenttia","status":"publish","type":"post","link":"https:\/\/themewp.inform.click\/fi\/korosta-kuuman-aiheen-viesti-joka-sisaltaa-yli-5-kommenttia\/","title":{"rendered":"Korosta kuuman aiheen viesti, joka sis\u00e4lt\u00e4\u00e4 yli 5 kommenttia"},"content":{"rendered":"\n<p>WordPress-blogia pit\u00e4ess\u00e4 t\u00e4rkeint\u00e4 on <strong>tarjota laadukasta, omaper\u00e4ist\u00e4 sis\u00e4lt\u00f6\u00e4, joka kiinnostaa lukijat<\/strong>. Jos sinulla on <strong>suosittuja viestej\u00e4, joissa on paljon kommentteja, sinun kannattaa harkita t\u00e4m\u00e4n kuuman aiheen korostamista<\/strong>. Se on loistava tapa kiinnitt\u00e4\u00e4 lukijoiden huomio.<\/p>\n<p>T\u00e4m\u00e4 on <strong>eritt\u00e4in helppo muokkaus, joka ei vaadi laajennusta<\/strong>, ja sen avulla voit visuaalisesti suodattaa blogiluettelon sis\u00e4lt\u00f6\u00e4 ja korostaa t\u00e4rkeit\u00e4 viestej\u00e4. Voit esimerkiksi valita korostamaan kaikki viestit, joissa on yli 5 kommenttia.<\/p>\n<p>Sukellaan ensin hieman WordPress-ydintiedostojen sis\u00e4\u00e4n, jotta saadaan selke\u00e4 k\u00e4sitys lopullisesta ratkaisusta.<\/p>\n<p>Jos olet tehnyt joitain muutoksia teematiedostoihin aiemmin, olet todenn\u00e4k\u00f6isesti n\u00e4hnyt jotain t\u00e4m\u00e4n kaltaista:<\/p>\n<pre><code>&lt;?php\n\/**\n* The template part for displaying single posts\n*\n* @package WordPress\n* @subpackage Twenty_Sixteen\n* @since Twenty Sixteen 1.0\n*\/\n?&gt;\n&lt;article id=\"post-&lt;?php the_ID(); ?&gt;\" &lt;?php post_class(); ?&gt;&gt;\n&lt;header class=\"entry-header\"&gt;\n&lt;?php the_title( '&lt;h1 class=\"entry-title\"&gt;', '&lt;\/h1&gt;' ); ?&gt;\n&lt;\/header&gt;&lt;!-- .entry-header --&gt;\n&lt;?php twentysixteen_excerpt(); ?&gt;\n&lt;?php twentysixteen_post_thumbnail(); ?&gt;\n&lt;div class=\"entry-content\"&gt;<\/code><\/pre>\n<pre><code> post_class<\/code><\/pre>\n<p>Jos etsit post_Class-sanaa WordPressin ydintiedostoista, l\u00f6yd\u00e4t helposti t\u00e4m\u00e4n osan wp-includes\/post-template.php-tiedostosta:<\/p>\n<pre><code>$classes = array_map( 'esc_attr', $classes );\n\/**\n* Filters the list of CSS classes for the current post.\n*\n* @since 2.7.0\n*\n* @param array $classes An array of post classes.\n* @param array $class An array of additional classes added to the post.\n* @param int $post_id The post ID.\n*\/\n$classes = apply_filters( 'post_class', $classes, $class, $post-&gt;ID );\nreturn array_unique( $classes );\n}<\/code><\/pre>\n<pre><code>apply_filters<\/code><\/pre>\n<p>Toimintomme t\u00e4m\u00e4n saavuttamiseksi n\u00e4ytt\u00e4\u00e4 t\u00e4lt\u00e4:<\/p>\n<pre><code>\/**\n* Function for adding custom css class to post_class for posts with minimum number of comments\n* Then styling of hot-topic css class can be done inside child theme style.css file or from WP Back end &gt; Appearance &gt; Customize\n*\/\nif (! function_exists('wpklik_function_css_class_for_highly_commented_posts')) {\nfunction wpklik_function_css_class_for_highly_commented_posts($classes, $class, $post_id) {\n$min_comments = 5; \/\/ change this number to your liking\nif (is_archive() || is_home()) {\nif (get_comments_number() &gt;= $min_comments) {\n$classes[] = 'hot-topic';\n}\n}\nreturn $classes;\n}\nadd_filter('post_class', 'wpklik_function_css_class_for_highly_commented_posts', 10,3);\n}<\/code><\/pre>\n<p>Toimintomme avulla k\u00e4sittelemme yksinkertaisesti jokaisen postauksen blogiluettelon ja arkistosivujen kommenttien m\u00e4\u00e4r\u00e4n, ja jos se on suurempi tai yht\u00e4 suuri kuin haluttu v\u00e4himm\u00e4ism\u00e4\u00e4r\u00e4 (oletusarvo on 5), v\u00e4lit\u00e4mme mukautetun kuuman aiheemme. css-luokka n\u00e4ihin artikkeleihin. T\u00e4m\u00e4 korostaa tehokkaasti kaikkia yksitt\u00e4isi\u00e4 viestej\u00e4, joissa on v\u00e4hint\u00e4\u00e4n 5 kommenttia.<\/p>\n<p>Jos vierailet nyt blogissa ja tarkastelet viestej\u00e4, joissa on yli 5 kommenttia, huomaat kuuman aiheluokan.<\/p>\n<pre><code>style.css<\/code><\/pre>\n<p>T\u00e4ss\u00e4 on esimerkki koodista, jota olen k\u00e4ytt\u00e4nyt t\u00e4h\u00e4n tarkoitukseen:<\/p>\n<pre><code>article.hot-topic:before {\ncontent: \"Trending !\";\nposition: absolute;\nleft: -20px;\ntop: -20px;\ntransform: rotate(-7deg);\ncolor: red;\nfont-weight: 600;\n}\narticle.hot-topic .entry-title a {\ntext-decoration: underline;\n}\narticle.hot-topic .entry-title a:hover {\ncolor: red;\n}\narticle.hot-topic span.comments-link a {\ncolor: red;\nfont-weight: 600;\n}<\/code><\/pre>\n<p>Ja lopputulos on t\u00e4m\u00e4:<\/p>\n<p><a href=\"https:\/\/themewp.inform.click\/wp-content\/uploads\/2022\/10\/post-280846-633e2e7b43d6f.jpg\" data-rel=\"lightbox\" ><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/themewp.inform.click\/wp-content\/uploads\/2022\/10\/post-280846-633e2e7b43d6f.jpg\" alt=\"Korosta kuuman aiheen viesti, joka sis\u00e4lt\u00e4\u00e4 yli 5 kommenttia\" ><\/a><\/p>\n<p>Toivottavasti joillekin teist\u00e4 t\u00e4m\u00e4 on kiinnostava ja hy\u00f6dyllinen. Jos on, \u00e4l\u00e4 unohda jakaa.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/wpklik.com\" class=\"external external_icon\">wpklik.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Korosta kuuma aiheviesti, joka sis\u00e4lt\u00e4\u00e4 yli 5 kommenttia. Se on helppoa ja k\u00e4yt\u00e4nn\u00f6llist\u00e4. Opi kuinka.<\/p>\n","protected":false},"author":1,"featured_media":274625,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[631,284,570],"tags":[843],"class_list":["post-371916","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bloggaaminen","category-seo-6","category-wordpressin-perusteet","tag-affiai-fi"],"_links":{"self":[{"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/posts\/371916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/comments?post=371916"}],"version-history":[{"count":0,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/posts\/371916\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/media\/274625"}],"wp:attachment":[{"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/media?parent=371916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/categories?post=371916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themewp.inform.click\/fi\/wp-json\/wp\/v2\/tags?post=371916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}