Articles of parse

Upgrading to 4.1 fixed parse error

In the past few days I’ve had reports that users weren’t able to access my site. They were just getting a blank page. I checked the error_log and found this. [22-Nov-2014 22:07:41 UTC] PHP Parse error: syntax error, unexpected end of file in /mysite/wp-includes/post.php on line 235 I was running v4.0 and I force upgraded […]

Custom Post Type Field Array parsing

I have a CPT Field named ‘course_location’ as a checkbox with values. When I use $field = get_field_object(‘course_location’); ‘<pre>searchDateArray’; print_r($field); echo ‘</pre>’; Which results in the following array Array ( [key] => field_56056d11c5dd6 [label] => Course Location [name] => course_location [_name] => course_location [type] => checkbox [order_no] => 3 [instructions] => [required] => 0 [id] […]

How to prevent someone from entering strings without making it available for translation?

I am working to make all strings in my plugin ready for translation by putting them under __() or _e() as per requirement. Now in future to avoid others in my team to add strings without making available for translation(bare strings), I want to add a code that runs may be on pushing the code(in […]

How to make modifications only to certain elements of an HTML string on the server-side?

Is there a similar way to select / perform DOM manipulation on the server-side (PHP) like the way jQuery works? For example, if I wanted to modify content of each <pre class=”raw”>…</pre> elements inside of a post content, in jQuery you can easily capture them all with: //In jQuery, this will obtain a collection of […]

Parse error after modifying the template menu

I made an edit in the template’s functions.php and now I can’t access my website. I know I have to fix the problem from the Cpanel but I’m now scared to do anything because I’ve tried once and the screen started flashing. This is the error I get: Parse error: syntax error, unexpected ‘<‘ in […]

Get parse_query filter to return slug instead of id

After much headache in the last week I feel like my problem is almost solved. I have been attempting to customize the admin edit.php page of custom post types to display and sort/filter custom taxonomies. I’ve frankensteined a collection of actions and filters from things found on the web but fear I may be using […]

How to use WordPress (PHP) functions in AngularJS partials files?

I am using AngularJS to load a list of my WordPress posts, however I can not get any of my PHP functions to work with my partials file. I’ve tried using something such as search.php instead of search.html but when doing so I get errors such as fatal error get_post_meta is undefined. Now I know […]

Get closest page ID from URL

Lets say on my WordPress website I navigate to: In this case I am looking at a post in a CPT called News. What I want to do is get the page ID thats closest to that URL. I know the closest page ID can be found at: So how do I loop […]

Check what is at URI (post, archive, etc…)

Is there a way or function where you can pass in a custom uri like uri-part/uri-part2 and we can check what is under this address? I want to check if a uri hosts a post, page, archive, category, tag, other taxonomy, custom post type archive or custom?

Correct regex for wp_embed_register_handler

THE GOAL I’m trying to parse a url and convert it to an embedded video player in my post’s content but I think my regEx is off or I’m not creating a provider correctly. THE CODE Here is what I have setup now. wp_embed_register_handler(‘brightcove’, ‘/([^/]+)/([^/]+)/index\.html\?videoId=([\d]+)/g’, ‘wp_embed_handler_brightcove’); function wp_embed_handler_brightcove($matches, $attr, $url, $rawattr) { // var_dump($matches, $attr, […]