New answers tagged

0 votes

Develop theme with demo default content, programmatically create pages

use after_setup_theme create your post and tags then save the data, add option key and only run your setup once, i.e. add_action( 'after_setup_theme', function() { $setupKey = '...
  • 211
0 votes

How react js and other Javascript Technologies works on WordPress plugin?

Yes, both libraries are already bundled with wordpress.
  • 106
0 votes

Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?

You should be able to do this with the theme_templates filter (see the get_page_templates() function). What you need is a function that walks through the sub-directories and returns all the page ...
3 votes

Theme.json: creating different sections of the color palette

No, writing as of Wordpress 6.0 there is no API for defining additional palette sections. The colour palette component hardcodes 3 PaletteEdit sub-components, theme, default, and custom, where custom ...
  • 53.8k
0 votes

How to Add Font Awesome Icons to WordPress Menus?

You can add directly svg as url format inside add_menu_page. Modified a little @Chris answer above. add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, ...
  • 1
0 votes

Where to put my code: plugin or functions.php?

To answer OP: custom post types and taxonomies Should go in a plugin as they define stuff on a structural/conceptional level, not a presentation level contact forms Are presentational should go in ...
  • 101
0 votes

Wordpress search results grouped by post type

Solution found by counting! It counts if there are any posts and if not then skips. <?php if ( have_posts() ) : ?> <?php $types = array('product' => 0, 'post' => 0, 'page' => ...
  • 11
1 vote

Show custom post type on post category page doesn't work / breaks navigation

The reason the menu is disappearing is because pre_get_posts applies to all queries on the page, including menus, your code is interferring with the menu queries. The is_main_query method should make ...

Top 50 recent answers are included