Passing different content to template parts

1. Simply call the template part in each place. <?php get_template_part(‘content’,’left’); ?> and <?php get_template_part(‘content’,’right’); ?> You would then create content-left.php and content-right.php templates. 2. A different approach would be to call do_action there instead. eg. <?php do_action(‘template_content_left’); ?> This could give you an extra level of control over the content template used. eg. in … Read more

Add a downloaded JS file to WordPress

You have to load your javascript Snippet inside your header. You’ll have to options: Edit your themes header.php and put the code before the closing tag Insert your code into the header with a custom function inside your functions.php function my_custom_js() { echo ‘<script type=”text/javascript”> jQuery(document).ready(function($){ jQuery(“#double-scroll”).doubleScroll(); }); </script>’; } // Add hook for front-end … Read more

wp_query (or hook) posts by date (id) in array then set post_type

Thank to @pietergoosen for “jokingly” giving me the answer. function gm_gather_posts_in_array() { $set_days_before=”1275″; $posts_to_be_processed = date(‘Y-m-d’, strtotime(“today – $set_days_before days”)); $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘date_query’ => array( array( ‘before’ => $posts_to_be_processed ) ) ); $posts_to_be_processed = new WP_Query( … Read more

Setting ‘post_format’

You can add an action to wp_insert_post(). The cool thing about it is the third parameter – $update, because it allows you to only set the post_format once, and you can change it later. This is necessary because the function wp_insert_post() is not only called on the creation, but also on update etc. add_action( ‘wp_insert_post’, … Read more

dropdown with no submit

You can use “get_page_link” function to Retrieves the permalink for the current page (if in The Loop) or any arbitrary page ID if passed as the first argument. something like this: <a href=”https://wordpress.stackexchange.com/questions/219011/<?php echo get_page_link( $page->ID ); ?>”><?php echo $page->post_title; ?></a> Reference: https://codex.wordpress.org/Function_Reference/get_page_link