How to retrieve current wordpress profile page URL?
How to retrieve current wordpress profile page URL?
How to retrieve current wordpress profile page URL?
CSV syntax for WP All Import upload without ACF
When I attempted something similar I experienced the same issue where the HTML code of the page I was generating the CSV from would be included within the CSV mixed with the data I actually wanted. The two things I figured out, after searching and reading and reading and searching was to use ob_end_clean(); before … Read more
Well this was a journey! The solution was ‘die’ and not exit AND use the add_action call that resulted in a notification PRIOR to any header call being called. The die forced the system to quit before attempting to write out the headers at the end of file. The final code that works: add_action( ‘template_redirect’, … Read more
Return of that function should have post ID, right? Then it’s straight get_post_meta() using that ID and name of your field. Update In your second code snippet $post is global variable, $post->ID is not tied in any way with return of stats_get_csv() function. You need something like from first example ($p[‘post_permalink’]), just figure out if … Read more
Aha, I figured it out! You have to use wp_remote_get(). I’m not exactly sure why at this point, but here’s what the code looks like: function display_csv_data_func( $atts ) { $file_path = “http://example.com/something/file.csv”; $response = wp_remote_get($file_path); $response_body = wp_remote_retrieve_body($response); return “<script>alert(‘” . $response_body . “‘);</script>”; } add_shortcode( ‘display_csv_data’, ‘display_csv_data_func’ );
To start with, you need to fix the define of CSV_PATH: define(‘CSV_PATH’,dirname(__FILE__)); as without that, $handle will be false – no file opened or data read. …then before you run it take another look becaue $col4 and $col5 are not set anywhere either…
With the help of @toscho pointing out get_post();, I was able to spit out a .csv with a blank template. At first, I had memory limit issues b/c of the amount of data, so I moved the site locally and was able to get everything I need with the get_post(); This is the gist of … Read more
Export WordPress Table to CSV from page
Your WordPress code is correct, the problem is the incorrect 2nd param to PHP’s frwite(), which needs to be a string, and you’re passing arrays. I think you want something like: fwrite ($fp, “$label\n”) ; fwrite ($fp, implode (‘,’, array_keys ($entries)) . “\n”) ; fwrite ($fp, implode (‘,’, array_values ($entries)) . “\n”) ;