How to use a custom field with add_rewrite_rule()?

You should use ‘post_type_link’ hook and register post type ‘project’ with (‘with_front’ => true) parameters ‘rewrite’ => array(‘slug’ => $slug, “with_front” => true), ==================================or===================================== add_rewrite_rule(‘^project/([0-9a-z]+)/?$’, ‘index.php?project=$matches[1]’, ‘top’); ==================================================================== function post_type_link_hook($link, $post) { add_rewrite_tag(‘%url_id%’,'([^&]+)’); if (‘projects’ == get_post_type($post)) { $urlId = get_post_meta($post->ID, ‘url_id’, true); //Lets go to get the parent cartoon-series name return str_replace(‘%url_id%’, $urlId, $link); … Read more

Create Biographies

A couple of notes here: You might find a custom post type to be better than using a built-in Page. You would create a post type called something like “players” or “football-players” and with it you’d have an archive. Very similar to how Posts and Categories work: you’ll have one URL for each Post but … Read more

List users by Year of Birth using a foreach loop to dynamically populate years and data

So, I solved this by doing a regular get_user() and putting it inside a for loop of years and ran the get_user on each year. $currentYear = date(‘Y’); $years = range($currentYear, 1900); foreach($years as $year){ $TotalArray = get_users(array(‘meta_key’ => ‘date_of_birth’, ‘meta_value’ => $year, ‘count_total’ => true, ‘meta_compare’ => ‘LIKE’, ‘role__in’ => ‘members’)); $thisYearsTotal = count($TotalArray); … Read more

How do I display specific custom posts, and how do I edit a post’s singular page?

Custom post types don’t need a template created for them. They will automatically use the archive.php and single.php of your theme. If you want to customize a page so that your portfolio and your regular blogs are different then you need to create 2 files. archive-postname.php (in this case it’s whatever you named your post … Read more

Problem with conditional woocommerce custom checkout field

Ok, I figured it out (finally) Instead of using the code above to add a new custom field, I changed it to this: add_filter( ‘woocommerce_checkout_fields’, ‘custom_override_checkout_fields’ ); function custom_override_checkout_fields ( $fields ) { $fields[‘order’][‘the_script’] = array ( woocommerce_form_field ( ‘the_script’, array( ‘type’ => ‘textarea’, ‘class’ => array(‘extracheckoutinfo form-row-wide’), ‘label’ => __(‘What is the script?’), ‘placeholder’ … Read more