Insert page content into another page with a changed variable

Assuming you want to replace it with some static value (well, you can always change this anyway), some kind of find and replace snippet like this can do the trick: $content = apply_filters( ‘the_content’, $post->post_content); // set the replacement string value $replace = “REPLACEMENT”; // make sure the quotes used are exact $find_start = “<param … Read more

Extending WP_Customize_Media_Control to return filename

I have noticed that WP_Customize_Image_Control does indeed return the filename instead of the ID, but this is only for images. That’s because the class extends WP_Customize_Upload_Control which has the type set to upload: class WP_Customize_Upload_Control extends WP_Customize_Media_Control { public $type=”upload”; public $mime_type=””; … } And for Customizer controllers using the above class, the JavaScript controller … Read more

Prevent redirect to wp-login.php

I guess you don’t have code on your new login form that supports ?action=lostpassword ? Your choices are either copy the relevant code from wp-login.php to your new form; you want the retrieve_password() function. Then you can post back to /login?action=lostpassword. use your own ‘lost password’ form, but post to /wp-login.php?action=lostpassword hook the lostpassword_redirect filter … Read more

Parse error: syntax error, unexpected ‘,’

You’ve got unbalanced and improperly placed closing parenthesis. There shouldn’t be the closing parenthesis after the ‘stylesheet’. Because the closing parenthesis is there, the PHP processor thought that was the end of the function’s parameters. Which caused the comma character after that to cause the error. Watch the balancing of your parenthesis (and quotes) as … Read more

Where is the PHP code generating an element?

You can ask a dozen developers how they work with themes or plugins and you’ll get a dozen different answers. My method is to use NetBeans to edit php files stored locally on my computer and then ftp (NetBeans upload) them to a test server with wp_debug turned on. NetBeans turns the theme or plugin … Read more

Form Submission Not Working In Custom Theme

WordPress uses Name, email post fields to do post comments, If you renamed the your form elements name attributes to be f-name and f-email then your issue will be resolved. I have made changes in below code and it is working now. <?php if($_POST[‘f-submit’]) { if(!$_POST[‘f-name’]) { $error=”<br>- Please enter your name”; } if(!$_POST[‘f-email’]) { … Read more

Add class to website based on post taxonomy

You can use the body_class filter in WordPress to add the Taxonomy Terms of a Custom Taxonomy as CSS classes to a post. The CSS class appears in the body element and is only used if the post has been assigned to the taxonomy. The code goes in your functions.php file. add_filter( ‘body_class’, ‘themeprefix_add_taxonomy_class’ ); … Read more