• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Logo

impressive pages: Webdesign und eCommerce

  • Home
  • Blog
  • Hosting
  • Contact

WordPress

How do I remove the word “MENU” from the hamburger menu in Genesis?

22. December 2021 Leave a Comment

How can I remove the word MENU from the Hamburg menu in Genesis?

The mobile menu (so-called hamburger menu) in Genesis has the text “Menu” next to the icon by default. This is of course not ideal for German websites. But there is an easy way to change that.

To do this, we add the following style statement:

button#genesis-mobile-nav-primary {
    font-size: 0;
}

in our CSS code. Ready!

There is also the option of adapting the theme code. However, the above solution is easier to implement. It is also recommended by the developers of the Genesis framework.

Filed Under: Genesis framework, mobile, WordPress

Remove website url field from WordPress comment form

22. December 2021 Leave a Comment

If you want to remove the URL field from the WordPress comment form, you can do so using the following code snippet:

add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
    if(isset($fields['url'])) {
       unset($fields['url']);
    }

    return $fields;
}

Filed Under: development, WordPress

WooCommerce product description (full product description) as a meta description in WordPress

22. December 2021 Leave a Comment

With the help of YOAST it is possible to display the product description as a meta description. This is done in the programmatic way as follows:

Insert the following code as a snippet in functions.php of the theme or using a plugin.

// callback für Ersetzung in YOAST SEO 
function get_fullDescription() {
    global $post;
    return $post != null ? $post->post_content : "";
}

// Registriere eigene YOAST-Variablenersetzung
function register_custom_yoast_variables() {
    wpseo_register_var_replacement( '%%fulldes%%', 'get_fullDescription', 'advanced', 'Full Description' );
}

// YOAST-Variablenersetzung bekannt machen
add_action('wpseo_register_extra_replacements', 'register_custom_yoast_variables');

Then under WordPress -> SEO -> Presentation in search results -> Enter products %%fulldes%% under meta description. Don’t forget to save!

Under SEO -> Presentation in search results -> P roducts -> Enter meta description %%fulldes%% . YOAST replaces the variable with the variable name.

But now the complete description is used. However, it would be better to observe the length specification for meta descriptions of the search engines. This is a maximum of 160 characters.

For this we need two more functions. With the replaceHtmlTags function below, we replace any existing HTML tags in the description, because we don’t want them in our meta description. With the second function wordTruncate we reach the length specification. The code ensures that it is not just separated after 160 characters and thus possibly cut off in the middle of the word, but that it is cut off after the last word that is still within the 160 characters.

function replaceHtmlTags($string) {
	return preg_replace("/<.*?>/", "", $string);
}

function wordTruncate($string, $desired_max_width) {
  $parts = preg_split('/([\s\n\r]+)/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
  $parts_count = count($parts);

  $length = 0;
  $last_part = 0;
  for (; $last_part < $parts_count; ++$last_part) {
    $length += strlen($parts[$last_part]);
    if ($length > $desired_max_width) { break; }
  }

  return implode(array_slice($parts, 0, $last_part));
}

The routine get_fullDescription from the code above is modified again a bit and looks like this:

// callback für Ersetzung in YOAST SEO 
function get_fullDescription() {
    global $post;
    return wordTruncate(replaceHtmlTags($post->post_content), 160);
}

The complete code looks like this:

// callback für Ersetzung in YOAST SEO 
function get_fullDescription() {
    global $post;
    return wordTruncate(replaceHtmlTags($post->post_content), 160);
}

// Registriere eigene YOAST-Variablenersetzung
function register_custom_yoast_variables() {
    wpseo_register_var_replacement( '%%fulldes%%', 'get_fullDescription', 'advanced', 'Full Description' );
}

// YOAST-Variablenersetzung bekannt machen
add_action('wpseo_register_extra_replacements', 'register_custom_yoast_variables');

function replaceHtmlTags($string) {
	return preg_replace("/<.*?>/", "", $string);
}

function wordTruncate($string, $desired_max_width) {
  $parts = preg_split('/([\s\n\r]+)/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
  $parts_count = count($parts);

  $length = 0;
  $last_part = 0;
  for (; $last_part < $parts_count; ++$last_part) {
    $length += strlen($parts[$last_part]);
    if ($length > $desired_max_width) { break; }
  }

  return implode(array_slice($parts, 0, $last_part));
}

Thus, without the chargeable YOAST SEO WooCommerce extension, we have managed to display the product description as a meta description.

WooCommerce short description as meta description

If, on the other hand, you want to use the short description as a meta description, YOAST SEO offers the function in the free version, albeit a bit hidden.

To use the short description as a meta description, under SEO -> Presentation in search results -> Products include the %%wc_shortdesc%% variable.

Good luck with your SEO project!

Do you have any further questions or need support, I would be happy to assist you. Write to me without obligation or give me a call.

contact impressive pages

Filed Under: SEO, WooCommerce, WordPress

Use WP-CLI for automatic updates

22. December 2021 Leave a Comment

WordPress offers the possibility to carry out updates automatically. The updates are also carried out during peak hours (during the day). WP-CLI can be used wonderfully to carry out the updates at a defined time.

Another aspect is the translation files of WordPress itself, the plugins and themes are currently not updated automatically by WordPress. Everyone knows that these updates have to be carried out manually in the dashboard on a regular basis. This can also be automated with WP-CLI . If we fail to update, we run the risk of English terms appearing on a non-English page or in the WordPress panel.

Cronjobs ("Scheduled Tasks") in Plesk
Cronjobs (“Scheduled Tasks”) in Plesk

In order to automate the updates we need a so-called cron job (at Plesk it is called ” Planned Tasks ” in German and is located under Websites & Domains in the right side menu) with which we run WP-CLI on our WordPress installation. Cronjobs can be used to execute time-controlled commands or call up URLs. Mail notification can also be set up each time it is called up or in the event of an error. The following explanations relate to a Linux hosting which is in> 99% of the time is the case with most. If you are one of the few who have Windows hosting, the steps have to be adjusted a little.

So that WP-CLI can be used, we have to download it and store it in our own web hosting or server. The package contains the executable “wp”. This should now be stored in the file system in web hosting (use either FTP, SFTP or Plesk’s file manager). In order for the file to actually be executed, it requires execution rights. To do this, set the execution rights with the Plesk file manager or FTP program (see Plesk documentation ). Now we are ready to create the planned task.

Create scheduled tasks in Plesk
Create scheduled tasks in Plesk

In Linux command line shells, in which the execution of the cron jobs takes place, there is the possibility to chain commands. With && commands are chained and executed in the order from left to right (e.g. Command1 && Command2 –MyParameters etc.). The operator & can also be used instead of &&. Then the following commands will only be executed if the previous command has run through successfully. In this case, it doesn’t make a big difference which operator we use for our automatic updates.

So that everything is really updated incl. of the translation files we use the following command:

cd /wordPressInstallation && wp core update && wp plugin update – all && wp theme update – all && wp language core update && wp language plugin update – all && wp language theme update – all

First we change to the WordPress installation directory with cd / wordPressInstallation (the WordPress installation is often located under / httpdocs ). If there are several WordPress instances, a planned task can be created for each page and the steps are repeated for each appearance. Then the update (or update check) of WordPress itself is initiated via wp core update and the update of all plugins and themes is started via wp plugin update –all and wp theme update –all . Here you can also restrict which plugins / themes the updates should be carried out for or which should be ignored.

The most interesting point is the wp language command. This allows the said translation files to be updated. This can be done accordingly for core (WordPress itself), plugins and themes.

So that wp can be used as a command, the path to the directory in which the executable file wp is located must be contained in the so-called PATH variable. To do this, add the following line to the .profile file (create file if necessary) in the main directory of the hosting:

PATH=/mybin:$PATH

/ mybin must be replaced accordingly by the path in which wp is located. Alternatively, the absolute path can be used in the cron jobs instead of wp , e.g. / mybin / wp core update . Then the extension of the PATH variable is not necessary.

Update WP-CLI regularly

So that WP-CLI is always up-to-date and therefore compatible with the current WordPress version, it must also be updated regularly. Smart with the following command.

wp cli update

We also create a planned task for this purpose. I run it in my customer hostings once a month. That is completely sufficient for the update frequency of WP-CLI.

Filed Under: development, Web hosting, WordPress

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3

Primary Sidebar

Search

Recent Posts

  • WooCommerce: Show free shipping only
  • Remove wrapper DIVs (.wrap) in Genesis
  • Remove the number of products in the category list from the category name
  • Change the number of similar products in WooCommerce
  • Genesis Visual Hook Guide

Categories

  • development
  • Genesis framework
  • Google Search Console
  • mobile
  • SEO
  • Uncategorized
  • Web hosting
  • WooCommerce
  • WordPress

Archives

  • May 2022
  • January 2022
  • December 2021
  • imprint
  • Data protection

Footer

!pages
Heinrich Franz
Wilhelm-Martin-Str. 4
76356 Weingarten (Baden)
instagram
+49 160 85 40 725
info@impressive-pages.de

In my Blog I publish articles about WordPress, Genesis framework und SEO.

© 2022 impressive pages

  • Deutsch