WordPress

How to add your own button to TinyMCE editor
How to add your own button to TinyMCE editor

Let’s expand on this topic a bit by slightly improving the code for creating a custom button in the WordPress text editor. It’s not a major change, but this code turned out to be useful in one of my projects. I hope it will be helpful for you too, as there's not much information in Russian about the TinyMCE WYSIWYG editor — and it’s quite an interesting topic.

read more...

How to Add a Custom Button to the WordPress Editor
How to Add a Custom Button to the WordPress Editor

In this article, we'll look at a simple example of how to create a custom button for the WordPress text editor.

For those who don’t know, WordPress uses the TinyMCE web editor script. It’s a free script, and judging by the fact that it’s used in this CMS (it was also used in Joomla in the past — not sure about now), it clearly has some advantages over other editors.

read more...

Work with CRON in CMS WordPress
Work with CRON in CMS WordPress

In this short note, I’ll show a simple example of working with cron in a popular engine like WordPress.

For a regularly recurring task (i.e., code that should run on a regular basis), you can use the following code snippet:

add_filter('cron_schedules', function ( $schedules ) {
	$schedules['10sec'] = array(
		'interval' => 10,
		'display'  => __('Every 10 sec'),
	);
	return $schedules;
});

add_action('init', function(){
	if(!wp_next_scheduled('post_event_cron_action'))
	{
		wp_schedule_event( time(), '10sec', 'post_event_cron_action');
	}
});

add_action('post_event_cron_action', function () {
	echo 'Mail sent';
	mail('test@example.com', 'Test subject', 'Test body');
});

read more...

How to Get Your Own Post Type in WordPress by Filtering by the Right Taxonomy
How to Get Your Own Post Type in WordPress by Filtering by the Right Taxonomy

To retrieve a specific post type in WordPress filtered by a custom (or built-in) taxonomy, use the following snippet:

$Posts = get_posts(array(
	'post_type' => 'my-post-type',
	'order' => 'ASC',
	'tax_query' => array(
	array(
			'taxonomy' => 'my-taxonomy',
			'field' => 'slug',
			'terms' => 'event'
		)
	),
	'meta_query' => array(
		'AND',
		array(
			'type' => 'NUMERIC',
			'key' => 'event_date',
			'compare' => '<', 'value' => time()
		),
		array(
			'type' => 'NUMERIC',
			'key' => 'is_archive',
			'compare' => '==',
			'value' => 0
		)
	)
));

read more...

How to Create a Child Theme in WordPress
How to Create a Child Theme in WordPress

Hello, dear blog readers!

Today, we’ll take a look at a standard topic for most WordPress-related blogs — creating a child theme.

Why might we need to create such a theme:

  1. We need to change the design of specific blog pages without affecting the rest of the theme's functionality.
  2. We need to change the functionality of a specific page — for example, the homepage or the comment form.
  3. We need to add new functionality.

Yes, of course, all of these changes could be made in the current theme — if it was developed by you or built on demand. But if you're using a theme from the WordPress repository, it's better to make changes using a child theme. Because when you modify the parent theme, and then update it, all your changes will be lost.

read more...