Tag Info

Hot answers tagged

7

You are thinking of WordPress templates as PHP application code. Essentially they are not that. WordPress templates by design are templates using Template Tags API. It is extra level of abstraction, that just happens to allow to use rest of PHP language too. The ease of template tags serves the popularity of WordPress and extremely low entry bar for people ...


4

As @cybmeta already pointed out, you are too early with your removal. So you have to defer the actual removal, for instance like so: add_action( 'after_setup_theme', 'wpdev_170663_remove_parent_theme_stuff', 0 ); function wpdev_170663_remove_parent_theme_stuff() { remove_action( 'after_setup_theme', 'et_pb_setup_theme' ); }


2

Code is not readable in comment so I am adding it here. With a little explanation. You will need to add full path of the image file to show them in theme. If your image is in theme directory then you will have to use theme directory path variable bloginfo('stylesheet_directory') with image name. So this is the code you will need to add in your theme files. ...


2

The loop is just an abstraction of the process of iterating over the posts returned by a query. As with all abstractions you pay some performance price for not using directly the language constructs like arrays, but it creates a more readable code (hopefully) as $q->hove_posts() is easier to grasp then ($I++ < count($q->$posts)). The main reason of ...


2

PSD files are typically included with premium themes as an extra to allow you to customize the image assets. You have to open those files in Photoshop, edit them, and export new versions to replace the png, gif, or jpg assets that came with the theme. There's nothing in WordPress core that deals with PSD files, and the specific details of how the PSD files ...


1

The functions.php file of child themes is loaded right before the parent theme functions.php, so when you run remove_action in child theme, the action you are trying to remove doesn't exist beacuse it is added later.


1

Every query object contains an array of the returned posts, so technically you could use foreach to display the posts, but I don't think it would simplify anything. First of all, you'll lose the loop start and end actions, and the ability to know if code is being executed within the loop or not, but the major thing you'll lose is the current post context - ...


1

WordPress data is all centered around the concept of "The Post" which is really little more that a colloquialism used to describe a complex array of data stored in the database. The pieces of data in that array make sense together in context. So technically, sure, you could extract all that data from that array with a foreach if you really wanted to. But ...


1

You can use em sizing to make the dashicons scale relative to the font size of their containing element. This should do the trick: .dashicons:before { width: 1em; height: 1em; font-size: 1em; } Then if your <h1> element has a font-size of 48px, your dashicon will as well.


1

You can use wp_add_inline_style to attach some css to dashicon style. Using that function everytime you add dashicons css via wp_enqueue_script you can automatically append some css and so modify default styles. Something like: add_action('wp_enqueue_scripts', function() { wp_add_inline_style( 'dashicons', '.dashicons { ...


1

Using after_switch_theme will activate the theme (which is fine as we want to run the check within the context of the new theme). If the dependencies are not fulfilled ($dependencies_missing = true;) we're going to notify the user via an admin notice and instantly switch back to the theme used previously (passed via after_switch_theme as $oldtheme) ...


1

The problem, as idiotic as it may seem, was that I had inadvertently included the template name of my standard subpage template into my landing page template. WP didn't know what to do with it...


1

Scripts and styles get output with wp_head and wp_footer functions. If you enqueue a style after wp_head, it will be output in wp_footer, which, while in practice will often work, means the theme's html will not validate. It's up to you (or whomever is building a theme/plugin) to enqueue styles early enough to be output in the head. All the data you'd need ...



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