Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)

Add minimum word count to Excerpt field To enforce a minimum word count for the Excerpt field before the Post status can be changed to pending, we will slightly alter s_ha_dum‘s code. It can be done by filtering wp_insert_post_data: function wcexcerpt($data){ if (!current_user_can(‘edit_others_posts’)) { $num = 5; // minimum word count if (str_word_count($data[‘post_excerpt’]) < $num) … Read more

How to limit the number of results for all query_posts on mysite

It is not that hard to enforce a hard limit on results: add_action( ‘post_limits’, function($limit) { $limits = explode(‘,’,$limit); if (isset($limits[1]) && 2000 < $limits[‘1’]) { $limits[1] = 2000; } $limit = implode(‘,’,$limits); return $limit; } ); I would not be surprised if that does not solve your problem though. Just searching over that many … Read more

Display metabox with date

In database, it stores the date details with prefix as _start and _end so you need to change the meta keys accordingly. Please have a look at the below code. <p>Start time details</p> <p>Date: <?php echo get_post_meta($post->ID, ‘_start_day’, true);?>.<?php echo get_post_meta($post->ID, ‘_start_month’, true);?>.<?php echo get_post_meta($post->ID, ‘_start_year’, true);?></p> <p>Hour: <?php echo get_post_meta($post->ID, ‘_start_hour’, true);?>:<?php echo get_post_meta($post->ID, … Read more

How to set a link to custom archieve page

I am working on my blog where I wish to have a archieve for only specific category post. If I understand you, you are doing this wrong. What you want to do is use pre_get_posts to restrict your archives to the one category. Something like this: function restrict_archives_to_cat($qry) { if ($qry->is_main_query() && $qry->is_date()) { $qry->set(‘cat’,5); … Read more

Load Pages Menu in single.php

Yes you can. <?php $args = array( ‘theme_location’ => ‘primary’, //change this value with coresponding menu area ‘menu_id’ => ‘main-menu’, //change this value with wanted menu ); wp_nav_menu($args); ?> menu_id is the name of menu created in WP admin>Menus. I create menu with name “Main menu” so I put main-menu there. That menu is connected … Read more