New answers tagged theme-development
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 $...
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', ...
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&...
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. ...
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 ...
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 ...
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;
});
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:
...
Top 50 recent answers are included
Related Tags
theme-development × 4453themes × 715
php × 431
plugin-development × 410
functions × 305
customization × 279
plugins × 268
css × 220
custom-post-types × 213
theme-customizer × 207
child-theme × 195
menus × 194
loop × 161
theme-options × 151
templates × 145
images × 125
widgets × 116
posts × 115
wp-query × 110
javascript × 107
categories × 104
jquery × 102
page-template × 89
pages × 88
block-editor × 82