php code crashes site – possible syntax error

It’s hard to debug only seeing a portion of your code. For starters, you’ve got two <?php opening tags at the top which would certainly cause an error. But I think that’s leftover from your copy and paste. Look at your php server log which will tell you what file and line number the error … Read more

AJAX Load more start with x posts

You need to set the offset in the query. To get the right offset value, you will need to store and send back the offset value to your ajax script (data-offset in the input or an hidden field). $args = array( ‘posts_per_page’=> 10, ‘post_status’=> ‘publish’, ‘offset’=> $_POST[‘offset’] ); $_POST[‘offset’] is coming from your button with … Read more

Setting Up PHP Workflow in WordPress

Having a local environment that is the same for all devs is pretty easy to setup using vccw.cc or basic-wordpress-vagrant. Use Git for plugins and themes — each as their own repo. Free private repos are available on Bitbucket. Pass your DB around using WP-CLI or wordmove to sync settings and content.

Editing a text file from plugin menu

First of all put these all code inside in init hook, and use plugin_dir_path() func to get plugin dir path. add_action(‘init’,function(){ $plugindir = plugin_dir_path( __FILE__ ); if(isset($_POST[‘addition’])){ $file_open = fopen($plugindir.”dates.txt”,”w+”); fwrite($file_open, $_POST[‘addition’]); fclose($file_open); } echo ‘<form action=”‘.$_SERVER[‘PHP_SELF’].'” method=”POST”> <textarea name=”addition” COLS=50 ROWS=20>’; $datalines = file ($plugindir.”dates.txt”); foreach ($datalines as $zz) { echo $zz; } echo … Read more

Add categories to a page with out using Custom Post Types

If you don’t want to attach the default post category taxonomy, you can always create a new one specifically for pages. Insert this into your functions.php file: add_action( ‘init’, ‘create_page_taxonomies’ ); function create_page_taxonomies() { register_taxonomy(‘page_category’, ‘page’, array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => _x( ‘Page Category’, ‘taxonomy general name’ ), ‘singular_name’ => _x( … Read more