• Zur Hauptnavigation springen
  • Skip to main content
  • Zur Hauptsidebar springen
  • Zur Fußzeile springen
Logo

CITROWEB Webdesign

Erste Wahl für Ihren Onlineauftritt

  • Home
  • Leistungen
    • Webdesign, Webentwicklung und Beratung
    • Online-Shops mit WooCommerce
    • Technische Unterstützung für WooCommerce-Shops
    • Suchmaschinenmarketing
      • SEO: Ihr Webauftritt erhält mehr relevante Besucher
      • SEA: Suchmaschinenwerbung für Ihren Webauftritt
    • Webhosting
  • Blog
  • Kontakt aufnehmen

Blog

Hide WordPress admin bar

8. April 2022

If you want to disable the toolbar for your own profile, click on „Users“ > „Your Profile“ in the top right corner of the WordPress admin interface and then disable the item „Show toolbar for me on the website“ in the middle right corner.

Hide WordPress admin bar if page preview

However, if you want to hide the toolbar when previewing a page that is being edited, this can be solved with the following code:

add_filter( 'show_admin_bar', 'show_admin_bar_if_not_preview' );
function show_admin_bar_if_not_preview($show_admin_bar) {
	return ( is_preview() ) ? false : $show_admin_bar;
}

Hide WordPress admin bar for all users

add_filter('show_admin_bar', '__return_false');

Kategorie: development, WordPress

Remove navigation menu from a page in Genesis themes

19. März 2022

There are several ways to remove or hide your primary and secondary navigation menus using the Genesis framework in WordPress.

The easy way is to hook into the execution via an action and remove the action responsible for the menu. To prevent the navigation menus from disappearing on all pages, a check is made beforehand to determine on which page the execution is currently taking place.

Remove primary navigation menu from home page

add_action('get_header', 'cw_child_remove_genesis_do_nav');
function cw_child_remove_genesis_do_nav() {
   if (is_home()) {
      remove_action('genesis_before_header', 'genesis_do_nav');
   }
}

If the primary navigation menu is included after the header, instead of genesis_before_header, genesis_after_header is used with remove_action (code line 4).

Sometimes it is also necessary to specify a priority parameter, as in the case of the genesis-sample-theme, if the action was registered with a priority. Line 4 then looks like this:

remove_action('genesis_header', 'genesis_do_nav', 12);

And already it works with the sample theme from Genesis.

Remove secondary navigation menu from home page

add_action('get_header', 'cw_child_remove_genesis_do_subnav');
function cw_child_remove_genesis_do_subnav() {
   if (is_home()) {
      remove_action('genesis_after_header', 'genesis_do_subnav');
   }
}

Remove primary navigation menu from a specific page

First, the ID of the page or post must be known. You can see them in the URL of the edit dialog of the page.

Edit URL page

The code to remove the main menu from the page with ID 7 looks like this:

function cw_remove_genesis_do_nav() {
   if (is_page(7) ) {
      remove_action('genesis_after_header', 'genesis_do_nav');
   }
}
add_action('get_header', 'cw_remove_genesis_do_nav');

Kategorie: Genesis Framework

Navigationsmenü von einer Seite entfernen in Genesis-Themes

19. März 2022

Es gibt verschiedene Möglichkeiten, Ihre primären und sekundären Navigationsmenüs mit dem Genesis-Framework in WordPress zu entfernen bzw. auszublenden.

Einfach geht sich es über eine Action in die Ausführung einzuklinken und die für das Menü verantwortliche Action zu entfernen. Damit die Navigationsmenüs nicht auf allen Seiten verschwinden, wird vorher geprüft auf welcher Seite die Ausführung gerade stattfindet.

Primäres Navigationsmenü von der Startseite entfernen

add_action('get_header', 'cw_child_remove_genesis_do_nav');
function cw_child_remove_genesis_do_nav() {
   if (is_home()) {
      remove_action('genesis_before_header', 'genesis_do_nav');
   }
}

Ist das primäre Navigationsmenü nach der Kopfzeile eingebunden, wird statt genesis_before_header, genesis_after_header verwendet bei remove_action (Codezeile 4) verwendet.

Manchmal ist es auch notwendig, so wie im Fall vom genesis-sample-theme einen Priority-Parameter mitzugeben, wenn die Action mit einer Priorität registriert wurde. Die Zeile 4 sieht dann so aus:

remove_action('genesis_header', 'genesis_do_nav', 12);

Und schon funktioniert es auch mit dem Sample-Theme von Genesis.

Primäres Navigationsmenü von einer bestimmten Seite entfernen

Zuerst muss die ID der Seite oder des Beitrags bekannt sein. Die sieht man z.B. in der URL beim Bearbeiten-Dialog von der Seite.

URL Seite bearbeiten

Der Code, um das Hauptmenü auf der Seite mit der ID 7 zu entfernen, sieht wie folgt aus:

function cw_remove_genesis_do_nav() {
   if (is_page(7) ) {
      remove_action('genesis_after_header', 'genesis_do_nav');
   }
}
add_action('get_header', 'cw_remove_genesis_do_nav');

Sekundäres Navigationsmenü von der Startseite entfernen

add_action('get_header', 'cw_child_remove_genesis_do_subnav');
function cw_child_remove_genesis_do_subnav() {
   if (is_home()) {
      remove_action('genesis_footer', 'genesis_do_subnav');
   }
}

Kategorie: Genesis-Framework

SVG wird in übersetzten Seiten nicht angezeigt – Datum wird aus der URL entfernt

14. Februar 2022

Wenn Sie das SVG Support-Plugin verwenden, werden Sie feststellen, dass die SVG-Bild-URL unvollständig ist, wenn das WPML Media Translation Plugin aktiv ist.

Ein Beispiel, wie die Bild-URL in den übersetzten Seiten aussieht:

Mit aktivierter WPML Media Translation: https://my-domain.com/wp-content/uploads/my-logo.svg
Ohne aktivierte WPML Media Translation: https://my-domain.com/wp-content/uploads/2022/02/my-logo.svg

Wie Sie sehen können liegt das Problem am falschen Pfad. Laut WPML liegt die Ursache in der Implementierung von dem Plugin SVG Support. Bisher ist das Problem nicht behoben worden.

Screenshot: SVG-Datei wird in übersetzten Seite nicht angezeigt (broken image icon), wenn WPML Media Translation aktiviert ist.
Screenshot: SVG-Datei wird in übersetzten Seite nicht angezeigt (broken image icon), wenn WPML Media Translation aktiviert ist.

WPML selbst bietet einen Workaround für dieses Problem an. Allerdings wird dort geraten Änderungen am Code vom SVG Support-Plugin vorzunehmen. Das ist nicht nachhaltig, da beim Update dieses Plugins die gemachten Änderungen verloren gehen könnten (wenn der Autor des Plugins genau diese Datei aktualisiert). Auch ist es kein guter Stil und von WordPress nicht empfohlen, Änderungen direkt im Code von Plugins vorzunehmen.

Da ich selbst auf das Problem gestoßen bin und eine Lösung wollte, die auch nach Updates stabil funktioniert, habe ich dazu eigenen Code geschrieben, den ich gerne nachfolgende weitergeben möchte.

Hier finden Sie die Lösung:

Um das Problem zu lösen, wird folgender Code der WordPress-Instanz hinzugefügt. Das geht mit dem Code Snippets Plugin oder wird in die functions.php des verwendeten Themes hinzugefügt.

Profis haben für solche Anpassungen ohnehin ein separates Plugin und fügen den Code dort ein.

function cw_svgs_generate_svg_attachment_metadata( $metadata, $attachment_id ) {
	if ( get_post_mime_type( $attachment_id ) != 'image/svg+xml' || FALSE === get_option('uploads_use_yearmonth_folders') ) 
        {
		return $metadata;
	}
	
	$metadata['file'] = date("Y") . '/' . date("m") . '/' . $metadata['file'];
	return $metadata;
}
add_filter( 'wp_generate_attachment_metadata', 'cw_svgs_generate_svg_attachment_metadata', 11, 3 );

Wichtig: Die SVGs müssen in WordPress -> Medien erneut hochgeladen werden, damit die Metadaten erneut erstellt werden. Erst dann erscheinen sie korrekt in den übersetzten Seite (ggf. automatische Übersetzung erneut anstoßen).

Ein paar Worte zur Lösung

WordPress bietet das Konzept von Filtern und Actions und das machen wir uns hier zunutze um uns in die Code-Ausführung von SVG Support von außen einzuklinken.

Die Funktion cw_svgs_generate_svg_attachment_metadata wird jedes Mal aufgerufen, wenn eine Mediendatei in WordPress hochgeladen wird. Wenn es sich nicht um eine SVG-Datei handelt oder die Option „Meine Uploads in monats- und jahresbasierten Ordnern organisieren“ in Einstellungen -> Medien nicht aktiviert ist, soll der Dateipfad nicht verändert werden und das Array wird genauso zurückgegeben. Andernfalls wird Jahr und Monat als Pfad ergänzt und das Array zurückgeliefert an die weitere Ausführung in SVG Support.

Der Dateiname steht bereits im Array $metadata, da wir über den Parameter Priorität (Wert 11) von add_filter, festgelegt haben, dass die Funktion nach der Filter-Funktion wp_generate_attachment_metadata, die durch SVG Support ausgeführt wird (dort wird ein niedrigerer Prioritätswert verwendet).

Kategorie: Entwicklung, WordPress, WPML

SVG is not displayed in translated pages – date is removed from URL

14. Februar 2022

If you are using the SVG Support plugin, you will notice that the SVG image URL is incomplete when the WPML Media Translation plugin is active.

An example of how the image URL looks in the translated pages:

With WPML Media Translation enabled: https://my-domain.com/wp-content/uploads/my-logo.svg
Without WPML Media Translation enabled: https://my-domain.com/wp-content/uploads/2022/02/my-logo.svg

As you can see, the problem lies in the wrong path. According to WPML, the cause is the implementation of the plugin SVG support. So far, the problem has not been fixed.

SVG is not displayed in translated pages at WPML
Screenshot: SVG file is not displayed in translated page (broken image icon) when WPML Media Translation is enabled.

WPML itself offers a workaround for this problem. However, it is advised to make changes to the code of the SVG support plugin. This is not sustainable, because when updating this plugin the made changes could be lost (if the author of the plugin updates exactly this file). Also, it is not a good style and not recommended by WordPress to make changes directly in the code of plugins.

Since I encountered the problem myself and wanted a solution that would work stably even after updates, I wrote my own code for it, which I would like to share below.

Here you will find the solution:

To solve the problem, the following code is added to the WordPress instance. This can be done with the Code Snippets plugin or added to the functions.php of the theme you are using.

Professionals have a separate plugin for such customizations anyway and paste the code there.

function cw_svgs_generate_svg_attachment_metadata( $metadata, $attachment_id ) {
	if ( get_post_mime_type( $attachment_id ) != 'image/svg+xml' || FALSE === get_option('uploads_use_yearmonth_folders') ) 
        {
		return $metadata;
	}
	
	$metadata['file'] = date("Y") . '/' . date("m") . '/' . $metadata['file'];
	return $metadata;
}
add_filter( 'wp_generate_attachment_metadata', 'cw_svgs_generate_svg_attachment_metadata', 11, 3 );

Important: The SVGs need to be re-uploaded in WordPress -> Media so that the metadata is created again. Only then do they appear correctly in the translated page (if necessary, trigger automatic translation again).

A few words about the solution

WordPress offers the concept of filters and actions and we take advantage of that here to hook into the code execution of SVG support from the outside.

The cw_svgs_generate_svg_attachment_metadata function is called every time a media file is uploaded to WordPress. If it is not an SVG file or the„Organize my uploads in month and year based folders“ option is not enabled in Settings -> Media, the file path should not be changed and the array will be returned the same. Otherwise, year and month are added as path and the array is returned to further execution in SVG Support.

The filename is already in the $metadata array, as we have specified via the priority parameter (value 11) of add_filter, that the function is executed after the wp_generate_attachment_metadata filter function executed by SVG Support (where a lower priority value is used).

Kategorie: development, WordPress, WPML

WooCommerce: Nur kostenlosen Versand anzeigen

21. Januar 2022

Standardmäßig zeigt WooCommerce alle Versandarten an, die dem Kunden und dem Inhalt des Warenkorbs entsprechen. Das bedeutet, dass andere Versandmethoden nicht ausgeblendet werden, wenn “kostenloser Versand“ verfügbar ist. Das ist aus UX-Sicht für den Checkout nicht optimal.

Die Funktion, alle anderen Methoden auszublenden und nur den kostenlosen Versand anzuzeigen, erfordert entweder benutzerdefinierten PHP-Code oder ein Plugin.

Den PHP-Code dazu hat WooCommerce auf ihrer Seite veröffentlicht: Anleitung und Code öffnen

Es gibt dabei die Möglichkeit alle anderen Versandarten auszublenden oder alle außer der Abholung vor Ort, je nachdem ob es im Shop angeboten wird.

Versandarten bei „Kostenloser Versand“ ausblenden mit Plugin Germanized

Verwendet man Germanized als Erweiterung für WooCommerce, so lässt sich die Funktion, alle anderen Methoden auszublenden und nur den kostenlosen Versand anzuzeigen, per Einstellung aktivieren. Die Einstellung lautet „Erzwinge kostenlosen Versand wenn die Methode zur Verfügung steht“ und ist unter WooCommerce-Einstellungen -> Germanized -> Allgemein -> Kasse zu finden.

Kategorie: WooCommerce

  • « Go to Previous Page
  • Seite 1
  • Interim pages omitted …
  • Seite 7
  • Seite 8
  • Seite 9
  • Seite 10
  • Seite 11
  • Interim pages omitted …
  • Seite 16
  • Go to Next Page »

Haupt-Sidebar

  • How to remove dashicons in WordPress frontend?
  • How do I create a website (homepage) with ChatGPT?
  • Can I create a website (homepage) with ChatGPT?
  • iOS restrictions re: bringing up the keyboard on programmatic focus
  • iOS restrictions re: bringing up the keyboard on programmatic focus
  • Remove user listing from WP-JSON
  • Benutzerauflistung aus WP-JSON entfernen
  • What does „Video is not the main content of the page“ mean?
  • Was hat es mit „Das Video ist nicht der Hauptinhalt der Seite“ auf sich?
  • Remove WordPress logo from toolbar
  • Efficient onboarding simplified: LearnSuite – the cloud application for digital onboarding
  • Wir stellen vor: LearnSuite – Die Cloudanwendung für digitales Onboarding
  • Howto: How do I create a website (homepage) with ChatGPT?
  • Howto: Wie erstelle ich mit ChatGPT eine Website (Homepage)?
  • Can I create a website (homepage) with ChatGPT?
  • Kann ich mit ChatGPT eine Website (Homepage) erstellen?
  • Set noindex nofollow via .htaccess HTTP header
  • Über .htaccess X-Robots-Tag noindex nofollow setzen
  • How to remove WordPress Dashicons in frontend?
  • Wie lassen sich Dashicons im WordPress-Frontend entfernen?
  • DSGVO (3)
  • GDPR (3)
  • Genesis Framework (10)
  • Genesis-Framework (9)
  • Google Search Console (4)
  • Google Search Console (4)
  • Linux (3)
  • Linux (3)
  • mobile (3)
  • Mobile (3)
  • Network (1)
  • Netzwerk (1)
  • SEO (5)
  • SEO (5)
  • Trends (3)
  • Trends (4)
  • Uncategorized (3)
  • Web development (1)
  • Web hosting (1)
  • Webentwicklung (1)
  • Webhosting (1)
  • WooCommerce (9)
  • WooCommerce (9)
  • WordPress (23)
  • WordPress (24)

Footer

Logo




© 2026 CITROWEB
  • Datenschutz
  • Impressum