How to create a radio button to alt between settings in wp_options table

fist of all set radio two radio button and give a name related like “cf_current_list” and have you set save button if yes then set code in functions.php file like if(isset($_REQUEST[‘buuton_nm’])){ if ( get_option( cf_current_list ) !== false ) { // The option already exists, so we just update it. update_option( cf_current_list, $_REQUEST[‘radio_btn_nm’] ); } … Read more

Popular Post Not Show

Try this without $i = 0; <?php $popular_days_ago = ‘$popular_days days ago’; $recent = new WP_Query(array( ‘posts_per_page’ => $number, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘meta_key’ => ‘post_views_count’, ‘date_query’ => array( array( ‘after’ => $popular_days_ago )) )); while($recent->have_posts()) : $recent->the_post(); ?>

Highlight Single Page Ancestor

So, I never did figure out how to do this without the plugin I mentioned. What fixed the issue was installing: wordpress.org/plugins/custom-post-type-parents. This plugin has a Settings page which allows you to choose the page that is the parent for your custom post type, then it adds the classes necessary to the wp_list_pages menu.

Adding a number to a date

You need get_the_time, not the_time to get the date (the latter echo‘s the value). You also need to re-evaluate how you’re trying to calculate the end date – you can’t just “add” the number of days. What if the event length was 3 but the start date was the 31st? if ( $event_length ) { … Read more

I want different post-thumbnail size depending on media size

You can use the function [wp_calculate_image_srcset()][1], a helper function to return the srcset attribute value for an image ID, the different sizes need to exist, otherwise the function return false. Here is what a link with srcset look like, <img class=”alignnone size-full wp-image-122491 ” src=”http://example.com/wp-content/uploads/2016/03/C0101-012.jpg” alt=”C0101-012″ width=”2000″ height=”1200″ srcset=”http://example.com/wp-content/uploads/2016/03/C0101-012.jpg 2000w, http://example.com/wp-content/uploads/2016/03/C0101-012-656×394.jpg 656w, http://example.com/wp-content/uploads/2016/03/C0101-012-1024×614.jpg 1024w, http://example.com/wp-content/uploads/2016/03/C0101-012-1080×648.jpg … Read more

Using get_the_excerpt in edit-post

I think (and assuming) you use (without code, it’s hard to know, how you proceed) add_meta_boxes() to do your job. Then your code is logically standing in custom functions. Your function to render the metabox, don’t get the $post global, if you didn’t define it, the function need to know from which post it must … Read more