Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

0 votes

How to get author ID when an author page is being viewed?

try is_author()){ $author_id=esc_attr(get_query_var('author')); if (empty($author_id) || !is_numeric($author_id)) { $author_id=sanitize_user(get_query_var('author_name')...
backups's user avatar
  • 101
0 votes

Pass media upload value to input field

Try to target the Id's of input fields rather than classes. That will work out fine. And in Save_Function, make sure that each image is saved seperatly and have its URL available.
Musab Khan's user avatar
0 votes

WordPress Customizer add_control Dropdown of Pages with Multi Select?

Yes, this is possible, but you will have to really, really want it. It's difficult, because WordPress does not natively support the multiple argument on select inputs in the customizer. You can see ...
cjbj's user avatar
  • 14.6k
0 votes

How do I redirect all 404 errors of a specific post type to another URL?

function unlisted_jobs_redirect(){ // Check if it's a 404 page if( is_404()){ global $wp_query; // Check if WordPress has determined the post_type from the request // and if it's the type you're ...
dikshit sethi's user avatar
1 vote
Accepted

Calling a function via a shortcode in javascript

I'm afraid the code you've shared is rather wonky and there isn't just one thing that is backwards. Here are the first few things that came into my mind. add_filter( 'learn-press/after-content-item-...
Antti Koskinen's user avatar
1 vote

Programmatically convert single classic block to individual blocks via PHP

I ended up writing a function that wraps the <p> tags in the block comments. This forced the content to be individual paragraph blocks in the editor. My content was only paragraphs but other ...
Tommizzy's user avatar
0 votes

do_blocks not working with a custom block

It could be that the block is processing CSS, and that CSS processing has already occured. You need to thus run the do block in the header, or that is the solution I've been told. I've not gotten it ...
Michael Parisi's user avatar
0 votes

How can I make my custom shortcode work in a Custom HTML Widget?

For the Custom HTML Widget it's better to use this hook: add_filter( 'widget_custom_html_content', 'do_shortcode' );
indigit's user avatar
  • 41
0 votes

Why PHP Parse unmachet after update to PHP8?

I'm having the same exact issue. Same message in PHP 8 but not in PHP 7.4. The code is properly indented, ect. and can't find a single issue.
Matt's user avatar
  • 1
0 votes

Get generated block styles programmatically

We can look at the source of the wp_head() function: function wp_head() { /** * Prints scripts or data in the head tag on the front end. * * @since 1.5.0 */ do_action( '...
Wongjn's user avatar
  • 266
2 votes
Accepted

Wordpress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted

Problem solved. If there's anybody that has the same problem as me, go into the *.php file where you're trying to render the block. Make sure that you're using the_content() in order to render the ...
Daniel V.'s user avatar
  • 131
1 vote

PHP If user is logged in & on home page redirect

Here is the full code, tested and working fine (to be added in functions.php) : add_action ( 'template_redirect', 'redirect_my_homepage' ); function redirect_my_homepage(){ if ( is_user_logged_in() &...
user2696419's user avatar
0 votes
Accepted

Send emails to individual subscribers when CPT post is deleted (trashed)

Just use the $subscriber_email[] array in the foreach() loop at the bottom of your function (where you are sending out the emails to all subscribers). It's not necessary to do any of the other data ...
ScottM's user avatar
  • 556
1 vote

Adding a css class to the gallery

If you look at the gallery shortcode you will see that you are using the wrong filter. With post_gallery you can override the complete html of the shortcode. Your code performs a str_replace on an ...
cjbj's user avatar
  • 14.6k
0 votes

Remove admin bar for subscribers

You can use "AdminBar Editor" Plugin for Editing Admin Bar Items: https://wordpress.org/plugins/admin-bar/ or, use the code below for hide Admin bar for Subscribers. function ...
Liton Arefin's user avatar

Top 50 recent answers are included