Hot answers tagged

4

I'm not sure if this is for front end or back end, so I'm going to handle both. BACK END You can make use of get_current_screen() or the $pagenow global. Here are two examples which you can add in a plugin or in your functions.php to check the relevant info on an admin page add_action( 'current_screen', function ( $current_screen ) { ...


3

Style.css contains File Headers which are needed to outline basic information about your Theme. The index.php file is meant to be the primary fallback file for your theme. It's the "there are no other templates available to display for these pages, so we will end up at index.php. Here's a diagram: In short, these two files are the minimum required files ...


2

Your research lead you to the correct answer. Internationalization (A.K.A i18n) is best practice and is not as complicated as it may seem. You'll be better off in the long run learning it now. @Pieter Goosen is 100% correct with his advise in response to your suggestion using variables and constants. Keep out of global scope (creating globals and ...


1

Your order of your if/else statement is wrong. You would want to have your complex condition (or most important condition) at the top and the simplest (or least important condition) at the bottom. if/else statements work on the basis that the first condition that hits true will be executed. In your example above, if you have a post that belongs to the ...


1

Custom post types are by default excluded from the main query except on taxonomy pages and custom post type archives. You can simply use pre_get_posts to correctly alter the main query (alter the query variables before the SQL query is build and executed) to your needs. Just a few notes on pre_get_posts pre_get_posts runs front end and back end queries, ...



Only top voted, non community-wiki answers of a minimum length are eligible