WordPress Infinite Scroll without using any plugin

For single article infinite scroll below is the solution single.php <div class=”blog-article-section”> <?php while( have_posts() ): ?> <div class=”blog-article”> <?php if( have_posts() ): the_post(); ?> <h2><?php the_title(); ?></h2> <p><?php the_content(); ?></p> <?php endif; ?> <div class=”pagination-single” > <div class=”next_post_link”><?php previous_post_link( ‘%link’,’Previous Post’ ) ?></div> <div class=”previous_post_link”><?php next_post_link( ‘%link’,’Next Post’ ) ?></div> </div> </div> <?php endwhile; … Read more

Inserting choice in database table

The main issue with your code is that the form submission will always have the same value. This could be seen by debugging $_POST where you check if $_POST[‘submit’] was set. I set up a custom database table and added some dummy data. I think this more or less mirrors your setup. Here is the … Read more

Why Can’t PHPUnit UnitTest My WordPress Website

Unit tests for WordPress are a tricky thing. If you need to test the code with a live database, etc. I would suggest using the official WordPress test suite. I’ve gotten unit tests running for a plugin using that method before, but it wasn’t pretty, and was fairly unreliable. If you need to do it … Read more

Create WordPress pages with PHP

You can programmatically create posts and pages using wp_insert_post or insert content using WXR files via WordPress’s import feature. To use wp_insert_post see the documentation here: http://codex.wordpress.org/Function_Reference/wp_insert_post A simple example: $my_post = array( ‘post_title’ => ‘hello’, ‘post_content’ => ‘This is my post.’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array(1), ‘post_type’ => ‘page’ ); … Read more