Theme Advanced Styles in Visual Editor and Paragraphs

If you always want <br/> instead of <p> for newlines you can change the TinyMCE configuration: forced_root_block: false, force_br_newlines: true, force_p_newlines : false, I think you cannot do this based on the context (use <br/> when in class=”box_note”, <p> otherwise), but it is an interesting question for the TinyMCE forum. Shift+Enter is indeed the standard … Read more

How to put a banner ad between post 1 and post 2 on homepage only

Register a widget, and call it on the front-page when the the_post action is called second time: add_action( ‘wp_loaded’, ‘wpse_80202_register_banner_widget’ ); function wpse_80202_register_banner_widget() { // used on the first page of main loop only register_sidebar( array ( ‘name’ => ‘Banner front-page ‘, ‘id’ => ‘frontpage_banner’, ‘before_widget’ => ‘<div class=”frontpage-banner”>’, ‘after_widget’ => ‘</div>’ ) ); } … Read more

How to attach region identifier to a pretty url?

Referencing this question I was able to resolve this issue: Need help with add_rewrite_rule To briefly display the changes I made here it goes, in my theme functions.php I added the following action: add_action(‘init’,’custom_rewrite_rule’); function custom_rewrite_rule(){ add_rewrite_rule(‘^student/([^/]*)/’,’index.php?pagename=student&country=$matches[1]’,’top’); } This above allows for my urls to be the pretty form of: {{site_url}}/student/ca/ {{site_url}}/student/us/ However this form … Read more

Change Default Image HTML

This will do: <?php /* * This filter only works with images, for all kind of media check: media_send_to_editor * The priority is set to 20 and it takes 8 arguments */ add_filter(‘image_send_to_editor’, ‘wpse_53577_img_wrapper’, 20, 8); // We are only working with the $html argument, but you can play with all of them function wpse_53577_img_wrapper($html, … Read more

Current theme broken – after server and domain migration

Try the XCloner plugin: http://wordpress.org/extend/plugins/xcloner-backup-and-restore/. I use XCloner to move sites between my live server and my dev server. It takes care of all the migration differences between the domain, database, etc. It preserves all my widget settings, custom menus, etc.

switch a theme different per user role

There’s current_user_can( ‘CAPABILITY’ ); (see @Codex Users & Roles to find the appropriate cap for your targeted role), that you can use to determin what theme you want to display. You can also check for is_user_logged_in() if you just want to differentiate between non-logged in and logged in users. Then you have the switch_theme() function. … Read more

Making the Header on the Twenty Ten Theme Less Tall?

To make the header on the Twenty Ten theme less tall (i.e. a height with fewer pixels) put this code at the bottom of your theme’s “functions.php” file (being sure to change the number 180 to whatever height you want): <?php add_action(‘twentyten_header_image_height’,’yoursite_header_image_height’); function yoursite_header_image_height($height) { return 180; // Modify this to whatever pixel height you … Read more

How to avoid loading style.css twice in child-theme?

You usually don’t need to enqueue a child theme’s stylesheet. The parent theme does that. This is a bit confusing, so I’ll explain. In most themes, Twenty Seventeen included, the stylesheet is loaded like this: wp_enqueue_style( ‘twentyseventeen-style’, get_stylesheet_uri() ); The trick to understanding what’s going on here is understanding what get_stylesheet_uri() does. When a regular … Read more