WebElaine
  • Member for 5 years, 4 months
  • Last seen this week
Disable block from editor based on post type
7 votes

You can use the allowed_block_types hook: <?php function wpse_allowed_block_types($allowed_block_types, $post) { // Limit blocks in 'post' post type if($post->post_type == 'post') { ...

View answer
Disable Gutenberg text-Settings in all blocks
7 votes

The closest I can find in the documentation is disabling custom font size (the text input) and forcing the dropdown font size to only contain "Normal". add_action('after_setup_theme', '...

View answer
Gutenberg - Custom blocks onClick not working?
Accepted answer
6 votes

The Block Editor's save() function doesn't save JS functions to the database to be run on the front end. To run JS on the front end, you need to save it as a separate file and enqueue that file ...

View answer
How to store ACF custom fields data in a custom table
Accepted answer
6 votes

It is possible to save ACF data in custom tables by using a separate paid plugin called ACF Custom Database Tables. However, if your goal is just to keep the database as light as possible, meevly.com'...

View answer
Default image for homepage when shared in social media
Accepted answer
6 votes

Several options: Out-of-the-box plugin If you're using Yoast WordPress SEO, you have a built-in setting for Facebook images. Under your SEO > Social menu, go to the Facebook tab and select an image ...

View answer
Where does Yoast SEO plugin sets the site/page title?
Accepted answer
6 votes

There's a wpseo_title filter you can hook into. Example: add_filter('wpseo_title', 'add_to_page_titles'); function add_to_page_titles($title) { $title .= $addToTitle; return $title; }

View answer
How to develop custom blocks without triggering validation errors
5 votes

You have two choices. The first one you've discovered: change the block's underlying code, and you will trigger validation errors. The benefit is, you're only including the JS currently required for ...

View answer
Add Archive Page Template via Plugin
Accepted answer
5 votes

WordPress has a template_include filter which you can use. // Add a filter to 'template_include' hook add_filter( 'template_include', 'wpse_force_template' ); function wpse_force_template( $template )...

View answer
How to get around iframes with WordPress?
Accepted answer
5 votes

That would be more of a question for the makers of Wrike, not WordPress, since it depends on whether or not Wrike has APIs or some other way to access their data. A quick glance at their site reveals ...

View answer
Need to take the first image out of posts and set it as the featured image
Accepted answer
5 votes

To get you started: Breaking your goal into smaller tasks will help a lot in figuring out how to do this. You probably want to: Do a custom query that finds all published posts Use a foreach loop ...

View answer
WordPress 4.8.1 php getting commented
5 votes

Using the <?php tag "correctly" - meaning the WordPress way - means you can't use it within post content. Some options you have: Use a shortcode instead. This will allow you to execute pre-...

View answer
Can I assign a template to a custom post type?
5 votes

For those reaching this thread through Google, WP 4.7 introduced templates for all post types. See Make WP Core for a full walkthrough. You're no longer restricted to one template for all of your CPT, ...

View answer
Custom Yoast Breadcrumbs URL
4 votes

That's an unusual setup - Yoast usually recognizes the right permalinks. You may want to consider changing the way you set up your custom post type, so that it has the desired names and URLs to begin ...

View answer
Need of separate security plugins for both root and subfolder sites Wordpress?
4 votes

It depends on the plugin. Some security plugins have settings that will check folders outside of the current WP install. Others don't. Some plugins may have complications if they are installed both ...

View answer
How can I develop a new theme in WordPress without disrupting the current site
4 votes

There are a couple of options. One: there are plugins that will let just certain logged-in users see the site in a different theme. You could use one of these and enable the new theme for yourself ...

View answer
Different color admin bars for dev, staging and production
4 votes

You can use a filter to set the admin color scheme, which includes colors for the admin bar: <?php // add a filter add_filter('get_user_option_admin_color', 'wpse_313419_conditional_admin_color'); ...

View answer
Wordpress roles - Protect administrator role
4 votes

It's a bit different in WP than in Drupal. First, the admin role is specifically designed to be the role that can do everything. Rather than try to restrict the admin role, it's best practice to ...

View answer
Need to convert string of term ids into comma separated integers for use in an arguments array
4 votes

You should be able to change these lines if ( !empty($terms) ) { foreach( $terms as $term ) { echo $term->term_id . ','; } } to this: if ( !empty($terms) ) { // create an ...

View answer
How to display 3 different loops in 3 columns on homepage
Accepted answer
4 votes

There's a third option, creating a front-page.php template file. It's similar to your option #1, except option #1 includes you creating a Page within the admin, and in your case it doesn't sound like ...

View answer
Wordpress Login page trashed
Accepted answer
4 votes

To solve this problem using a file manager (or FTP), rename your plugins folder. You can rename it anything - for example, "backupplugins". This will disable all plugins. You'll also need to clear ...

View answer
Difference between admin and user admin
3 votes

A "user admin screen" (or interface page) is a page in wp-admin for managing users. An "admin screen" (or interface page) is any page in wp-admin, which includes user admin screens ...

View answer
Add a div of content within the_content after a certain block
Accepted answer
3 votes

Yes, add_filter() is what you're looking for, but to identify a specific block, you want the render_block hook. <?php add_filter('render_block', function($block_content, $block) { // Only for ...

View answer
Which action is triggered when a theme was modified?
Accepted answer
3 votes

Anytime changes are saved in the Customizer, there is a customize_save_after hook. For theme updates, you can use the upgrader_process_complete hook - you pass it various arguments including 'type' =&...

View answer
Custom recent-posts shortcode's thumbnail image not in line with rest of code
3 votes

The problem is: the_post_thumbnail() outputs its content immediately. It's basically like echoing instead of returning. To fix it, you should be able to just replace the_post_thumbnail('thumbnail', ...

View answer
How to change the amount of posts previewed on a page?
3 votes

You're missing an s. $query->set('posts_per_page', '1'); However - you probably don't want to do this for every query, since that affects everything - widgets, back end, everything. You should ...

View answer
Gutenberg Additional CSS Class without modifying theme?
3 votes

Depending on your goal, you can add custom CSS for blocks in several ways. Theme Adding it "themewide" by either using a theme's Custom CSS area or creating a child theme could be used either to ...

View answer
Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
3 votes

This just means they moved the component. Replace this part: const { PanelBody, SelectControl, ServerSideRender, TextControl, ToggleControl, } = wp.components; with const { serverSideRender } = ...

View answer
Shortcode under a Shortcode Multiple times Possible?
Accepted answer
3 votes

Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within. So, for example, if your [shortcode]...

View answer
Custom post type archive with page as parent url
3 votes

Yes. First, unregister the post type. (None of the actual data will be deleted if you already have posts.) Then, re-register it with 'rewrite' => array('slug' => 'page-name/custom-post-type-...

View answer
Update wordpress theme without customization loss
Accepted answer
3 votes

Download a copy of the theme - if it's available in the WordPress repository, grab that. If it's a premium theme, have the client provide their credentials to download, or just have them provide the ....

View answer
1
2 3 4 5
20