Undefined property: WP_Post_Type::$ID

Try changing the get_queried_object()->ID to get_queried_object_id(). All the get queried object may not have a property name $ID. So this get_queried_object_id gives the $queried_object_id property value, which gets set on instantiation of WP_Query class. If the $queried_object_id isn’t set then it’ll give you 0.

The Point of Using apply_filters()

The point is to allow developers to customise aspects of your theme or plugin. When calling apply_filters() you provide a name and a value that you want developers to be able to filter. For your example: $array = apply_filters( ‘du/class/method’ array( ‘index’ => ‘value’, ‘index’ => ‘value’, ‘index’ => ‘value’, ‘index’ => ‘value’, ) ); … Read more

Detect when any plugin is activated or deactivated

There are few solutions. You can use activate_plugin and deactivate_plugin hooks for example. But… As far as I understand you right, you want to get notified whenever list of plugins get changed and not when a plugin is activated or deactivated. So the easiest way will be hooking onto update_option. add_action(‘updated_option’, function( $option_name, $old_value, $value … Read more

Change words on ‘Log in’ and ‘Register’ buttons on Woocommerce

You will need to add the following code to your theme’s functions.php file. If you haven’t already you should create a child theme, so you don’t lose your edits when the theme updates. Update the Log In text function custome_login_btn(){ add_filter(‘gettext’, ‘custome_login_btn_text’, 10, 2); } function custome_login_btn_text($translation, $text){ if (‘Log In’ == $text) { return … Read more

Is it possible to require approval before a page edit is made live?

Unfortunately, WP Core does not support this type of workflow. Plugin requests are considered off-topic here because plugin functionality can change and some plugins don’t last, but I think it would be helpful to the community (and OP) to know that Oasis Workflow satisfies these basic requirements. The downside is, the editors who can’t publish … Read more

How to add css class to a specific set of images?

You can use the get_image_tag_class filter which passes the attachment ID as an argument: apply_filters(‘get_image_tag_class’, string $class, int $id, string $align, string|array $size) So you can use: function my_image_tag_class($class, $id, $align, $size) { // Logic to check your attachment IDs if($some_logic) { $class .= ‘ no-lazy-loaded’; } return $class; } add_filter(‘get_image_tag_class’,’my_image_tag_class’); If you have an … Read more