Query WordPress Database and Post HTML Table

$html= “<table>”; foreach($result as $r){ $html .=”<tr>”; $html .=”<td>”.$r->post_title.”</td>”; $html .=”<td><a href=””.get_the_permalink($r->ID)””>”.$r->post_title.”</a></td>”; $html .=”</tr>”; } $html .=”</table>”; echo $html; To avoid the depreacated usage of PHP code snippets you can wrap it in a shortcode and use anywhere in a page/post content editor function Stack_308511_post_grid( $atts ) { $atts = shortcode_atts( array( ‘limit’ => 10, … Read more

jQuery ajax empty exeption on wordpress

As I said in the comments. The problem was on api side. Error: (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). How to solve: Add this to .htaccess of api <IfModule mod_headers.c> Header set Access-Control-Allow-Origin: myUrl </IfModule>

Why debug.log doesn’t work?

Based on this question: You have @ini_set(‘display_errors’, 0); – which will tell PHP (not WordPress) to stop displaying errors. WordPress requires errors to be turned on in order for it to pass them to the appropriate place. define(‘WP_DEBUG_DISPLAY’, false); or define(‘WP_DEBUG’, false); should take care of hiding them on the front end for you.

How can I re-use PHP code across different pages?

You’re looking for something similar to PHPs require or include function. In WordPress we can use get_template_part( ‘example-folder/template’ ); to get template.php from the example-folder. You should also look into the get_template_part function to see the capabilities. If you’re wanting to include outside variables into these, you can use PHP globals.

How to login via wordpress api and get user details?

1. Install and activate JWT Authentication for WP REST API plugin, also install WP REST API plugin 2. Now you can run any wordpress default api from mobile app or any other source or by postman. for example hit this url from your app or by postman. https://example.com/wp-json/wp/v2/posts 3. By app or by postman, When … Read more

Unexpected error with class-wp-hook.php on WordPress

Somewhere in the theme, the WP_Maintenance_Mode class method is hooked to the filter or action. But when the hook is executed, this class doesn’t exists or is not yet included. I suspect that in the theme (file functions.php) this class is hooked to some event, but it is defined in an inactive plugin (I’m guessing … Read more