Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]

Let’s unwrap it to more readable form: <?php if ( ! empty( get_the_author_meta( ‘facebook’, $part_cur_auth_obj->ID ) ) ) { ?><a href=”https://wordpress.stackexchange.com/questions/305172/<?php echo get_the_author_meta(“facebook’, $part_cur_auth_obj->ID);?>”> <i class=”fab fa-facebook-f”></i> </a><?php}?> End the last line is a problem. There are no spaces around curly bracket and it causes the error. Just change it to <?php } ?> and … Read more

Add post with approval by the admin

Set New User Default Role to Contributor. Change user role of existing users as well, if needed. UPDATE Add this to your functions.php file. It’ll allow your contributor and author users to add WooCommerce products. And then set default user role to contributor as I suggested before. function wpse_306836_wc_custom_permission( $args, $post_type ) { if ( … Read more

How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286

Replace ‘call_user_func_array’ with name of the function to be called to output the page content. add_action(‘admin_menu’, ‘personalised_menu’); function personalised_menu() { add_menu_page( ‘Page Title’, ‘Blog’, ‘edit_posts’, ‘menu_slug’, ‘display_main_page’, ‘dashicons-welcome-write-blog’ ); add_submenu_page( ‘menu_slug’, ‘Add New Page’, ‘Add New’, ‘edit_posts’,’add_new_page’, ‘display_secondary_page’ ); } function display_main_page() { echo ‘Content of “Page Title”‘; } function display_secondary_page() { echo ‘Content of … Read more

Separation of presentation and code – WordPress

TLDR; Separate your view and business logic, or don’t – WordPress doesn’t care either way. Additional template engines aren’t necessary. Start small developing with vanilla PHP & WordPress; just build something that works, then separate it’s view and business logic. Continue refactoring as you learn and the project grows. When you’re comfortable with theme and … Read more

Single Quotes in .php file doesn’t load website

Your input line is enclosed in single quotes, so when PHP sees the single quote inside that string, it thinks you’re done with the string and jumping back into PHP. The way to fix this is to escape quotes inside the string so the single quoted words inside ga() change from ‘send’ to \’send\’.

How to get post ID in a Page?

You should not use globals directly. There are some nice wrapper functions in the WordPress API. If you want to retrieve the ID of the current post or page just use get_the_ID(). Without any test … you could write the functionality in this way: $file_id = get_post_meta( get_the_ID(), ‘sound_s’, true ); $file_url = wp_get_attachment_url( $file_id … Read more