Inserting A Feed and Sidebar into an HTML Page

The typical definition of static page is plain text file, typed by hand or generated by software either. By definition static pages cannot have back-end powered dynamic functionality. There are quite a few approaches to integrating WP (or anything really) with static page, typical being: convert static page to dynamic completely – turn it into … Read more

Querying multiple meta_keys in WordPress SQL query

WordPress Provides a native functions to query these kind of things very easily like WP_User_Query $args = array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => $meta_key1, ‘value’ => $search1, ‘compare’ => ‘LIKE’ ), array( ‘key’ => $meta_key2, ‘value’ => $search2, ‘compare’ => ‘=’ ) ) ); $user_query = new WP_User_Query( $args );

If Elseif Query

This cannot work. It has to look like the following (or similar): <?php if (get_post_meta($post->ID, ‘TourURL’, true)) { ?> <div class=”tourenquiryonline”> <h2>Book or Inquire</h2> This tour can be booked online. </div> <?php } elseif (get_post_meta($post->ID, ‘bhid’, true)) { ?> <div class=”tourenquiryonline”> <h2>Book</h2> This tour can be booked online via the form on the right hand … Read more

How to have post count after each listed category

For showing category count on your loop – foreach($categories as $category) { echo ‘<li><a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in: %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a>&#32;&rsaquo; (‘. $category->count .’)</li>’; } And for showing count with wp_get_archives function, use show_post_count in argument … Read more

Display pages from specific page template

Use get_post_field(‘post_content’, $product_page->ID ) to get the content outside loop. <?php $product_pages_args = array( ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘page_library_html.php’ ); $product_pages = get_pages( $product_pages_args ); ?> <?php foreach ( $product_pages as $product_page ) { echo ‘<div id=”posts” class=”flex_100″>’; echo ‘<div id=”library_title”><a href=”‘ . get_permalink( $product_page->ID ) . ‘”>’ . $product_page->post_title . ‘</a></div>’; echo ‘<div … Read more