WordPress import media error

Admittedly, this is a guess. The exporter, in the versions I have used, does not save your files to a local disk. It creates an XML file with references to your images on a server somewhere. When the importer reads the XML file, it will download from that server and upload to your new installation. … Read more

Putting php inside an echo php shortcode

You’re close but not quite. do_shortcode expects a string so give it one! If function() returns a string you can echo do_shortcode( ‘[shortcode]’ . function() . ‘[/shortcode]’ ); If function() directly outputs, you can capture its output using output buffering //start the buffer ob_start(); function(); //i.e pdf_print_popup(); //store out output buffer $string = ob_get_contents(); //clear … Read more

WP Business Directory Manager Plugin Admin Listings?

You can test by the admin login name: $current_user = wp_get_current_user(); $my_user = $current_user->user_login; if (strpos($my_user,’admin’) !== false) { // test for the admin username if ( !$data->listing_id && ( !$listing_cost || current_user_can( ‘administrator’ ) ) ) { wp_update_post( array( ‘ID’ => $listing_id, ‘post_status’ => ‘publish’ ) ); //update post to publish } }else{ if … Read more

How would I use this filter to change the output of the date format to “Twitter time”?

WordPress has a core function human_time_diff that does what you want, using it with the filter you provide you have someting like so: add_filter(‘latest_tweets_render_date’, function( $created_at ){ $date = DateTime::createFromFormat(‘D M d H:i:s O Y’, $created_at ); return sprintf( ‘%s ‘ . __( ‘ago’ ), human_time_diff( $date->format(‘U’) ) ); });

PHP in CSS file?

You can use wp_add_inline_style(). Let’s assume you enqueue your css like so add_action( ‘wp_enqueue_scripts’, ‘add_my_style’ ); function add_my_style() { wp_enqueue_script( ‘my_style’, get_template_directory_uri() . ‘/mystyle.css’ ); } Then you can change the function like so: function add_my_style() { wp_enqueue_script( ‘my_style’, get_template_directory_uri() . ‘/mystyle.css’ ); $style = “#mainnav li:after { content: url(‘{theme_url}/images/nav-divider.png’); }”; $style .= “#another-example { … Read more

Troll the hackers by redirecting them

I understand this isn’t exactly what you’re looking for but these hackers are most likely bots and redirecting them won’t matter at all. I suppose you could modify the below code if you reallllly wanted to but this will redirect anybody looking for an author back to your homepage. RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{QUERY_STRING} ^/?author=([0-9]*) … Read more

Parse error: syntax error, unexpected end of file

I just want to add to the two answers given on this matter. It is important to know that if you use if($the_query->have_posts() ) : you will need to close that with endif; otherwise you will also get the same parse error as described.

Update post title from external file?

Sometimes I use this code when I want to run WordPress externally. update.php function find_wordpress_base_path() { $dir = dirname(__FILE__); do { //it is possible to check for other files here if( file_exists($dir.”/wp-config.php”) ) { return $dir; } } while( $dir = realpath(“$dir/..”) ); return null; } define( ‘BASE_PATH’, find_wordpress_base_path().”https://wordpress.stackexchange.com/” ); define(‘WP_USE_THEMES’, false); global $wp, $wp_query, … Read more