How-to articles, tricks, and solutions about WORDPRESS

Facebook SDK returned an error: The "state" param from the URL and session do not match

This error message appears when the SDK is being used to make an OAuth request to Facebook, and the "state" parameter in the URL doesn't match the "state" value that was stored in the user's session.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)

This is a PHP error message that indicates your script is trying to use more memory than the amount specified in the PHP configuration.

get all the images from a folder in php

To get all the images from a folder in PHP, you can use the glob function.

Get Category name from Post ID

To get the category name from a post ID in PHP, you can follow these steps:

Get custom product attributes in Woocommerce

To retrieve custom product attributes in WooCommerce, you can use the get_post_meta() function.

How do I generate a custom menu/sub-menu system using wp_get_nav_menu_items in WordPress?

To generate a custom menu/sub-menu system using wp_get_nav_menu_items in WordPress, you can follow these steps:

How to display Woocommerce Category image?

To display a category image in WooCommerce, you can use the woocommerce_subcategory_thumbnail hook in your theme's functions.php file.

How to display woocommerce sale price or regular price if there is no sale price

In WooCommerce, you can display the sale price or regular price of a product using the following code snippet:

How to fix Warning Illegal string offset in PHP

The "Illegal string offset" warning in PHP occurs when you try to access an offset of a string variable as if it were an array.

How to write own DD() function same as laravel?

To create your own version of the Laravel DD() function, you can create a new function in your codebase and have it take in any number of arguments.

Multiple excerpt lengths in wordpress

In WordPress, the length of the excerpt (the summary text displayed on the homepage or archive pages) can be controlled by the theme or by a plugin.

Nginx serves .php files as downloads, instead of executing them

There are several reasons why Nginx may serve PHP files as downloads instead of executing them.

PHP fopen() Error: failed to open stream: Permission denied

This error message is indicating that the PHP script is trying to open a file using the fopen() function, but the script does not have the necessary permissions to access the file.

Proper URL forming with a query string and an anchor hashtag

To form a proper URL with a query string and an anchor hashtag in PHP, you can use the http_build_query() function to create the query string and concatenate it to the base URL using the ?

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

net::ERR_HTTP2_PROTOCOL_ERROR is an error that occurs in the Google Chrome browser when there is an issue with the HTTP/2 protocol.

Woocommerce get products

You can retrieve a list of products in WooCommerce using the get_products() function.

WordPress - Check if user is logged in

In WordPress, you can use the function is_user_logged_in() to check if a user is currently logged in.

WordPress Issue: Cannot modify header information - headers already sent by

This error message appears when a PHP script is trying to modify the headers of an HTTP response after the headers have already been sent.