Loading files for theme and child theme (Require)

get_theme_file_uri(), get_theme_file_path(), get_parent_theme_file_uri() and get_parent_theme_file_path() are relatively new (introduced in WordPress 4.7) functions that have a couple of significant advantages over using get_template_directory(). get_theme_file() and get_theme_file_path () allow you to reference files in your theme in a way that allows them to be replaced by a child theme. This lets you do things like allow … Read more

How to attach different React Components to different Dom Roots using the new WP wordpress/scripts webpack/babel

ok, after hours of research and trying different things I found my answer. You can extend the WordPress webpack config file. Here is documentation from WordPress https://developer.wordpress.org/block-editor/packages/packages-scripts/#advanced-usage So here is my new webpack config file located in my theme root directory.I have moved the SinglePost React code into its own file, singlePost.js. Now when I … Read more

Getting the wrong page ID

As mentioned in the comments, you are trying to get the ID in the taxonomy archive (template-taxonomy.php) which is not a post object and has no record in the database. It just tries to show some posts and you may get the first post ID when you use get_te_ID() function in that archive page. Using … Read more

Can I change a variable in a content part while calling it?

Currently, you have your variable defined below the include which would be too late. If you defined the variable above the include it should be accessible by whatever file is included. $hssHeading = “A new different Title”; include( locate_template( ‘cp/heroSectionSmall.php’, false, false ) ); <!– heroSectionSmall.php –> echo $hssHeading; Maybe a better solution though is … Read more

Using Font Awesome as post thumbnail

Load the FontAwesome library properly in your theme via wp_enqueue_scripts hook, then instead of using: <img src=”https://wordpress.stackexchange.com/questions/353224/XY” class=”card-img-top” alt=”…”> use the icons fa fa-whatever in your theme. Sure, you have to do some checks based on category etc. I’d try something like this: <?php // functions.php function wpse_script_loading(){ // This can be local or via … Read more

Showing Co-Authors on post page

Your error is that you’ve written an if inside the sprintf argument list. You can’t do that. Instead, you could use the ternary operator, which has syntax <condition> ? <result if true> : <result if false> e.g. $byline = sprintf( __(‘by %s’), function_exists(‘coauthors_posts_links’) ? (‘<span class=”author vcard”>’ . coauthors_posts_links( null, null, null, null, false ) … Read more