New answers tagged

1 vote

wp_script_add_data doesn't seem to work

Introduced in WP 5.7.0 (a few months before this post), the wp_script_attributes filter can be used to add arbitrary attributes. Example: add_filter( 'wp_script_attributes', static function ( array $...
Caleb's user avatar
  • 1,725
0 votes

Update Multiple Post Meta for the Same Post In One call?

You can also serialize the array $metaValues = array( 'key1' => 'value1', 'key2' => 'value2', // ... as many key/values as you want ); update_post_meta($postId,'post_meta_name', ...
el Reiz's user avatar
0 votes

Bring your own theme to PHP 8

I have found the error. In the header.php an undefined constant was tried to be accessed. So instead of the following wrong code: <?php if ($pagetitle == pagetitle_1){ $pt1 = "pagetitle_1&...
johannes_k's user avatar
0 votes

Show posts assigned to multiple categories in current category page

That's because that's what you're asking for: 'category__in' => array($category), It's only going to show posts in that category. You shouldn't be using get_posts() or WP_Query() in category.php. ...
Jacob Peattie's user avatar
1 vote
Accepted

Show category name in category.php when posts assigned to multiple categories

For the heading on a category archive use either: the_archive_title(); Or: single_term_title(); The first one can be used on the template for any archive, while the second should only be used on ...
Jacob Peattie's user avatar
0 votes
Accepted

How can I ping update-core.php with a script?

WP-CLI was updated to include a new global parameter that allows the execution of arbitrary PHP code before the main command runs. This allows you to pass the is_admin() check that some themes and ...
Elkrat's user avatar
  • 138
1 vote

Call to undefined function get_current_screen() on my localhost

maybe your code run before admin_init. Add it to the action: add_action('admin_init', function(){ $screen = get_current_screen(); echo $screen; });
amiad's user avatar
  • 151
0 votes
Accepted

Why does customize_register only load inside of functions.php for me?

In the second version you're running your code as a wp_enqueue_scripts hook. This is for frontend scripts and isn't called in the admin site. For that you need to hook admin_enqueue_scripts as well: ...
Rup's user avatar
  • 4,157

Top 50 recent answers are included