Tag Info

Hot answers tagged

2

Redefining a WordPress core function that might be used all over the place by the core, the theme or plugins isn't a very good idea in my opinion. Because it might be used in those occasions expecting the default value to be what default is, which might lead to breaking things. So it is actually not just not a very good idea, it is a terrible one - in my ...


2

I haven't tested this but theoretically you could do something like this (Using the Codex as an Example): function load_custom_wp_admin_style() { $pageArr = array(1, 2, 3); if(isset($_GET['post']) && in_array($_GET['post'], $pageArr)){ wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/admin-style.css', false, ...


1

I ended up modifying slightly to use data-filter instead of rel. Works perfectly in combination with the isotope j-query plugin. add_filter( 'get_image_tag', function( $html, $id ) { $dataFilter = array(); foreach( (array) get_the_category( $id ) as $cat ) { $dataFilter[] = $cat->slug; } ...


1

<?php $defaults = array( 'before' => '<p>' . __( 'Pages:' ), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __( 'Next page' ), ...


1

You're right. The code you had didn't use any logic to determine whether to add the CSS class or not. Try this: function skips_add_update_status($classes) { //Instantiates the different date objects $created = new DateTime( get_the_date('Y-m-d g:i:s') ); $updated = new DateTime( get_the_modified_date('Y-m-d g:i:s') ); $current = new ...


1

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( "get_address" => "mg_admin_address", "get_phone" => "mg_admin_phone", "get_fax" => "mg_admin_fax", "get_email" ...


1

Here is a great example. How to display featured post thumbnails in WordPress feeds paste this code snippet in your theme functions.php file // display featured post thumbnails in WordPress feeds function wcs_post_thumbnails_in_feeds( $content ) { global $post; if( has_post_thumbnail( $post->ID ) ) { $content = '<p>' . ...


1

When it comes to the template hierarchy, WordPress will indeed look in the child theme directory before loading from the main theme. For all other non-specific WordPress files (like functions and 3rd party includes), it's entirely up to the main theme to decide how to load them. Unless the theme is using locate_template to load these includes, or is ...


1

The $hook_suffix global (copy of which you are getting passed to the hook) doesn't go into such detail. However there is plenty more of context to check. In modern WP versions bulk of it is via get_current_screen() which returns WP_Screen object with plenty of stuff (in this case you would want to check id and post_type properties likely). As for post's ...



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