Hot answers tagged

15

The "classic" TinyMCE editor has two dropdowns: formatselect for paragraph styles and styleselect for character styles - which can also contain paragraph styles, to make it more confusing. The configuration in WordPress by default only shows the format dropdown. If you apply a custom stylesheet to the editor, TinyMCE can use it to pick up the classnames and ...


12

I created a Kint plugin that works really well. I also integrates with the Debug Bar plugin. You can download it at: http://wordpress.org/extend/plugins/kint-debugger/ There are a few functions to help you out with WordPress specific globals: dump_wp_query() dump_wp() dump_post() For printing arrays in a styled, collapsible format you would do the ...


8

I ran into this problem a year or so ago, and found a fix here. Open PHP.INI in a text editor of your choice (normally you can find php.ini in your php install dir) Change the recursion limit to 200x normal, that is, set: pcre.recursion_limit=20000000 Change the backtrack limit to 100x normal, that is, set: pcre.backtrack_limit=10000000 Stop and start the ...


8

There actually are several ways to handle the Wordpress editor wrapping shortcodes in <p> tags. This code shows probably the simplest way to do it...just a simple and short function you need to drop into your functions.php file. Once you do, no more tags around your shortcodes that are on their own line! function wpex_clean_shortcodes($content){ ...


8

If you look at the page source, you'll see that <body> has been given a class page-id-1199. You can use that in your stylesheet to specify styles for that page alone. .page-id-1199 #map { /* custom styles */ }


8

The default content type is 'text/plain' which does not allow using HTML. You can set the content type of the email by including a header like "Content-type: text/html" $headers = 'Content-type: text/html;charset=utf-8' . "\r\n"; $headers .= 'From: XXXXXX.com <info@xxxxx.com>' . "\r\n"; $subject = 'Registration from xxxxx.com' . "\r\n"; ...


7

I'm using something like this: date('F, Y', strtotime($data[0]->post_date));


7

wordpress.com supports code syntax-highliting. You can read all about it here: http://en.support.wordpress.com/code/posting-source-code/ for your specific example use: [sourcecode language="java"] package com.jameselsey.domain; import java.util.ArrayList; import java.util.List; import com.google.android.maps.GeoPoint; import android.app.Application; /** ...


7

You can install and use Krumo with WordPress (or any php app really). there's the Hikari Krumo plugin that simplifies use, though check the comments there, there's an error that you'll need to manually fix to get it working with latest WP. There's also the WordPress Debug Bar plugin which you might find useful. EDIT- Another option I've recently discovered, ...


6

If this is how it looks: <img class="alignleft size-medium wp-image-8530" alt="..." src="#" width="413" height="275" /> <img class="alignleft size-medium wp-image-8529" alt="..." src="#" width="413" height="275" /> Then you have to put them together like this: <img class="alignleft size-medium wp-image-8530" alt="..." src="#" width="413" ...


5

For this kind of stuff, I wrote REF (requires PHP 5.3). Among many other features, it displays contents of DocBlock comments and linkifies PHP-internal classes, methods and functions (links point to the PHP manual). It also handles WordPress functions (links point to queryposts.com). Here's the output of $GLOBALS at the setup stage of WordPress in HTML mode ...


5

Alright so I've already updated this question a ton and it's starting to get overloaded, so I figured I'd write this as an answer even though it isn't a full one. Extrapolating from @bueltge's answer, I actually went back and found his previous post in question. In that post, there was a plugin listed that I've never seen before: "Preserved HTML Editor ...


5

This is one of the reasons why HTML markup is removed from excerpts in the first place, to prevent such issues like this from occurring however, where there's a will, there's a way... You can, through using regular expression, close the open tags applicable to the excerpt only and you might want to take a look at the following link for some ideas, Close ...


5

I’ve done something similar taking the simple approach of adding a CSS class to titles based on their character count. That CSS class then decreases letter-spacing and/or font-size. // Count the characters, taking Unicode into account $chars = mb_strlen($post->post_title); // For every 10 characters after the first 20, add a size $size = max(0, ...


5

Yes you can. It's [code] *your code here* [/code] and you can even hint the language: [code lang="php"]<?php echo 'test'; ?>[/code]. This is the method I prefer (quick to write). There seem to be other ways as the following resource explains: Support: Code » Posting Source Code (wordpress.com)


4

After you post your content, WordPress will pass the_content() function through a number of filtering function's. There are four of them, wptexturize(), convert_smilies(), convert_chars(), and wpautop(). All of these are defined in wp-includes/formatting.php and are referenced in wp-includes/default-filters.php. To remove these filtering functions you can ...


4

There is a clue in wp-includes/formatting.php in the function wptexturize: $default_no_texturize_shortcodes = array('code'); ... $no_texturize_shortcodes = '(' . implode('|', apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes) ) . ')'; Try using this filter to add a shortcode to the array: function my_no_tex( $shortcodes ) { ...


4

I think your question is a perfect example for the XY Problem. In WordPress you do not create such a menu in a post editor. You use a menu. Once you start thinking about your problem from this point, everything is easy. :) First register a custom navigation menu for this list in your theme’s functions.php: add_action( 'wp_loaded', ...


4

The excerpt is created in -> wp-includes/formatting.php with this code: function wp_trim_excerpt($text) { // Fakes an excerpt if needed global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace('\]\]\>', ']]&gt;', $text); $text = ...


3

At first, I think this problem was solved since WP version 3.5; see ticket 19666 in trac. But the tinyMCE have a hook there give us the chance to change the content inside the editor and you must not parse on output on frontend. A small source script. I have no test this with a current WP version, was a older solution for a customer. Add this source via ...


3

function myshortcode( $atts, $content = null ) { return strip_tags($content,'br'); } add_shortcode('myshortcode','myshortcode'); But I am unclear why you are you adding newlines in the first place if you don't want them.


3

There are no hooks in wpautop(), at all. Given that this is possibly the most complained about function in the WordPress world, it is odd that there are none but there you go. What you will need to do is remove the filter: remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); Create a version that does what you want, and ...


3

Wordpress automatically ads the <p> tags to the content. So it shows up while loading the content. This is with the filter wpautop. So we will remove this filter for the image post type only. You can manage this by adding the following code in functions.php file. // Add the filter to manage the p tags add_filter( 'the_content', ...


3

The problem is that the_sub_field() echoes the Subfield, so in your conditional the field company_name gets echoed. However, this function does not return true, so the conditional is not met. You need to use another if statement: if ( get_sub_field('company_name') && get_sub_field('company_name') != '' ) { // echo it }


3

You can use sanitize_title() function: $string = "This is title string"; // return "this-is-title-string" $slug = sanitize_title( $string ); You can also filter the result of sanitize_title() function using sanitize_title filter: add_filter( 'sanitize_title' , 'sanitize_filter_callback', 10, 3 ); function sanitize_filter_callback( $title, $raw_title, ...


3

The quick fix is to wrap your image tags in div tags. That will prevent WP from wrapping the images in P tags. Then, you could give the divs a class for further control of appearance/arrangement.


3

This is an older question, but here's the answer for future generations: WordPress will check the styles against a whitelist and it will still strip the style attribute if none of the styles are safe. The default whitelist is: text-align margin color float border background background-color border-bottom border-bottom-color border-bottom-style ...


3

There are several ways to deal with this problem. You could have a look for some syntax highlighter plugin, those will also bring you coloured text with highlighted keywords etc. pp. This is probably nice, if you use code quite often. I use SyntaxHighlighter Evolved. If you want to do this by hand, <code> is probably the HTML-element you want to use, ...


3

This is a known issue and will be taken care of soon, assuming you are using the "Twenty Eleven" theme: see this link. The bundled Twenty Eleven theme has some styling issues for pages with sidebars (See Trac ticket #36510)


3

To format number, you can use the function number_format_i18n (it's not documented now, but you can see its source here). Its work is format the number based on the language. You might want to look at number_format (PHP built_in function, and is used by number_format_i18n) to have more control to decimal point and thousand separator. In your case, this code ...



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