The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”

The best way to customize a navigation menu is to use a custom ‘walker’ function.. Here are the steps how to achieve the customization that you want! Create a “wp-custom-nav-walker.php” file in your theme directory for a new custom ‘walker’ class. Extend the Walker_Nav_Menu class and copy the class’ function that you want to modify … Read more

Remove class that has been added by parent theme

If you want to apply a filter to the same content another function has filtered, change the priority argument (which should have been named _execution_order_) to a higher number. So … add_filter( ‘body_class’, ‘my_body_class’, 11, 2 ); … will make sure my_body_class() will be called after another_body_class() that has been registered with 10: add_filter( ‘body_class’, … Read more

How can I include PHP-Code to my post?

You can edit the single.php and/or content-single.php files in your theme. Then it depends what you mean by “some”. You could apply some conditions to your code (only certain categories, certain tags, certain specific post IDs only, etc.) You could also create a custom post type “myspecialposts” and create single-myspecialposts.php (codex)

Match checkbox data with page title to show certain items

I managed to figure it out myself reading around, solved it with this: <div id=”grid”> <?php $args = array( ‘depth’ => 0, ‘child_of’ => 411 ); $pages = get_pages(array(‘child_of’)); $grid_title = $post->post_title; foreach($pages as $post) { setup_postdata($post); $fields = get_fields();?> <?php if($fields->company_name != “”) : ?> <!– Any new tags will need to be added … Read more

wp_delete_post deletes all posts instead of just expired ones

In case anyone else needs the code, this is how I solved it. @pieter-goosen was right, I did need to query the correct posts, but the real trick was matching the date format from the jquery datepicker when running the post query. Check the date formats below, jquery is ‘yy-mm-dd’, and the php equivalent is … Read more

Create a post variable processing page

You see a lot of code out there which includes wp-load.php or wp-blog-header.php to use the WordPress API within a php page loaded outside the context of WordPress. There’s often a better way to accomplish this. It’s also worth noting that any plugin which does that will get rejected from the WordPress.org plugin repository, with … Read more

Loop through child images of a parent for a Nivo Slider

To get attached (i.e. child) images of a post, try using get_children(). e.g.: <?php $child_image_args = array( ‘post_mime_type’ => ‘image’, ‘post_parent’ => $postID, ‘post_type’ => ‘attachment’ ); $child_images = get_children( $child_image_args ); ?> Which returns an associative array of child images. Then, just loop through them, e.g. using wp_get_attachment_image(), to output. e.g.: <div id=”nivoslider”> <?php … Read more