How do I create a numbered list with PHP? [closed]

This is pure PHP. $items = get_post_meta($post->ID, “item-specific-meta”); $item_id = 1; $output=””; foreach ($items as $item) { $output .= ‘<label for=”item-‘.$item_id.'”><input id=”item-‘.$item_id.'”/>’.$item.'</label>’; ++$item_id; }

Basic function call on init failing

I am going to suggest that what you are doing is overly complex, at least insofar as I understand you. You can determine whether your shortcode has been registered using the Core function shortcode_exists, which returns a boolean. As far as I can tell, using that should provide completely equivalent functionality to your code above.

Help getting previously visited pages ID

get_page_by_path() should help you here. Something like this <php $prev_url = isset($_SERVER[‘HTTP_REFERER’]) ? $_SERVER[‘HTTP_REFERER’] : ”; if ( $prev_url ) { $prev_path = str_replace( home_url(), ”, $prev_url ); $page = get_page_by_path( $prev_path ); } That should give you the page object, where you can access it’s ID like so – $page->ID.

How do I get an external php page to load using javascript

If you’re trying to load a script from an external source (as your code suggests), please don’t use that article as a reference. It’s littered with bad code, and the comments on the page state several times that it’s outdated and points you to a new article. Here’s how you register and enqueue a script … Read more

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