New answers tagged

1 vote
Accepted

Post and page content not displaying in search results

The problem in your code is that your function is only returning the content when is_page() is true, which is not on the default search results page, where is_search() is true. Likewise, the content ...
user avatar
  • 31.3k
1 vote
Accepted

PHP File_exist() not working - Checking if File Exist in WordPress Theme Directory

Most of this code is unnecessary. You're attempting to convert a URL to a path when you could just use the function that returns a path. $path = get_theme_file_path( 'archive.php' ); if ( file_exists(...
user avatar
1 vote
Accepted

Hide Heading if ACF Field is empty

Move the outer(of the two) div.local_faq inside the if statement which checks if the faq field is set, because that’s the outer parent container. Also it would make sense to change the outer container ...
user avatar
  • 2,315
0 votes

Navbar- disable "onClick" drop-down

This approach uses global variable to return false for link click in desktop but true on mobile and tablet. Also works for resized windows. $(document).ready(function () { win_width = $(window)....
user avatar
  • 101
1 vote

searchform.php override not working

The person who posted this question is probably taking this Udemy course because I recognize the code: Complete WordPress Developer Course - Plugins & Themes I'm also taking the course and here's ...
user avatar
0 votes

How to add CSS class to custom logo?

You can use get_custom_logo_image_attributes filter add_filter( 'get_custom_logo_image_attributes', function( $custom_logo_attr, $custom_logo_id, $blog_id ) { $custom_logo_attr['class'] = 'your-...
user avatar
  • 427
0 votes

How to move page template files like page-{slug}.php to a sub-directory?

Use the filter {$type}_template_hierarchy to alter the templates that WP searches. Example: move page's templates in a subdirectory and remove the "page-" prefix. add_filter('...
user avatar

Top 50 recent answers are included