send meta box input data without publish button

You can get the post id like this var post_id = $(‘input[name=”post_ID”]’).val(); See this full working code. BTW its only save the value to the meta in the ajax it won’t save it on the publish button you need to add another hook with another function. you can’t use the same function that you used … Read more

Reading CSV values and showing them in PHP

Not too hard really… $csvdata = file_get_contents($filepath); $lines = explode(“\n”, $csvdata); // split data by new lines foreach ($lines as $i => $line) { $values = explode(‘,’, $line); // split lines by commas // set values removing them as we ago $linevalues[$i][‘name’] = trim($values[0]); unset($values[0]); $linevalues[$i][‘country’] = trim($values[1]); unset($values[1]); $linevalues[$i][‘color’] = trim($values[2]); unset($values[2]); // assign … Read more

Load Meta box value into div AJAX [duplicate]

Add data attribute data-post-id for the post id. Eg. HTML: <ul> <li><button class=”play_next” data-meta-key=”url-1″ data-post-id=”<?php the_ID(); ?>”>Video 1</button></li> … </ul> Missing data attributes in js. $( this ).data( ‘metaKey’ ); should be $( this ).data( ‘meta-key’ ); and $( this ).data( ‘post_id’ ); should be $( this ).data( ‘post-id’ ); E.g. Jquery: jQuery( document ).ready( … Read more

PHP Use Declared array Variable inside already Declared Array

This is more a generic PHP question than anything to do with WordPress, but I’d suggest setting the value in the constructor: class test { public $basicCols; public $optList = array( ‘one’ => ‘One’, ‘two’ => ‘Two’ ); function __construct() { $this->basicCols = array( array( ‘title’ => ‘KEY’, ‘field’ => ‘slug’, ‘options’ => $this->optList ), … Read more

How to customize posts in WordPress by using HTML and CSS?

the first thing you need to do is implementing the html template you desire to something that called wordpress template hierarchy is good to start with blank wordpress theme like underscores.me, so you can freely custom your own template so, after your files is ready, you can learn about wordpress theme customizer im giving you … Read more