Tag Info

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 ...


9

You can add a hebrew shortcode to wrap around your hebrew text and then use the CSS2 direction attribute to indicate the text direction. e.g.: In your themes functions.php: function hebrew_shortcode( $atts, $content = null ) { return '<p lang="he" DIR="RTL">' . $content . '</p>'; } add_shortcode( 'hebrew', 'hebrew_shortcode' ); Your ...


7

you can do it like this: //add my_print to query vars function add_print_query_vars($vars) { // add my_print to the valid list of variables $new_vars = array('my_print'); $vars = $new_vars + $vars; return $vars; } add_filter('query_vars', 'add_print_query_vars'); then add a template redirect based on that query_var: ...


5

Take a look at your page source. The offending area is a section of content that's being output after the closing </html>. Judging from some of the links in that appended area, I'd say there a good chance you've been hacked, unless these look like yours: <div style="text-indent:-9999em"> <a rel="follow" ...


5

Try this (you may need to bootstrap WP by loading wp-load.php, depending on where you put this code). $args = array( 'post_type' => 'post', 'post_status' => 'publish', //'posts_per_page' => -1 //uncomment this to get all posts ); $query = new WP_Query($args); while ( $query->have_posts() ) : $query->the_post(); $f = ...


5

Simple answer: add_shortcode( 'hidemytext', '__return_false' ); But shortcodes should never be used like that. Imagine what happens when the plugin or theme with that shortcode is turned off: everyone can see the content now. This is not very user friendly. So switch the logic: show nothing or the bare shortcode tag by default, show the content only if ...


4

There's not a native WordPress function to retrieve text only, but you can use WordPress filters and regex code to target this specific problem. To get unformated text, use get_the_content() function. To apply all filters, use it this way( see codex: http://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage ): $content = ...


4

The answer by bungeshea is not ideal as in many cases: You don't want to strip everything from <br>, <p> etc. You want it as a default behavior for your WP visual composer which the above code will delete In many cases it is considered as "hacking the core" as this is changing the default core behavior of WP - for example such a thing will not ...


4

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, ...


4

Hi @Nam Gi VU: I'm pretty sure that's not possible directly. What you could do would be to export all posts to a text file, use a search and replace in a text editor and then import them back in deleting all the posts before you reimport them. Be careful to change a copy of the export in case your search and replace corrupts the file and makes it fail to ...


4

A little tip a lot of people don't know about. You can copy/paste an image url into the upload field and it will be auto uploaded into your blog. Right click the image you want to save and select copy image URL (chrome) In your blog click Add Image--> Select Files ( from computer)-->paste url into the upload dialog where it says "file name". This ...


4

In your functions.php file where the custom post type is registered do you see: 'supports' => array('title','editor','thumbnail') or something similar? If so remove 'editor'


3

This is because the images are defined as floating to the left. To solve this, you can add a clear: both to the <h4> elements (it probably won't hurt to do this in the stylesheet - will there be a situation where you need a title that exists next to a float?).


3

A cursory search doesn't turn up any plugins that do this ... but you could use the built-in exporter as an example for building out your own plugin. It's located in /wp-admin/includes/export.php. Essentially, it's a PHP page that queries the database to get all of your posts, then dumps the content into a pre-build XML template that can be imported later. ...


3

The plugin repository contains a few options that you could use. At a glance this one looks promising.


3

I ended up using userabuser's answer with a small modification, because global $post doesn't seem to exist on init. You can instead just query for post in querystring, like so: function remove_editor() { if (isset($_GET['post'])) { $id = $_GET['post']; $template = get_post_meta($id, '_wp_page_template', true); if($template == ...


3

You have multiple options here, depending on the amount of flexibility you want to give the editor of the text blocks. Create a custom loop with WP_Query. See our examples and the Codex page for usage. Then you print the excerpts of the page these boxes are linked to. You can use attachments (images) and the full formatting here. Use widgets. See our ...


3

Try removing (image), like this: <?php $content = get_the_content(); $content = preg_replace("/<img[^>]+\>/i", " ", $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; ?>


2

Are you sure editor use <i> for italics? I'm almost sure it uses <em>. However, if you want to be absolutely sure there are no <i> in your post content, let editor do what it want and then replace <i> with <em> before creating/updating posts, hooking wp_insert_post_data filter, just like: ...


2

The wpautop() function adds <p> and <br> tags to your content in order to preserve line breaks. If you would rather add these tags yourself, then you can remove the filters which apply this function to the post content: remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); If you would like to keep the automatic ...


2

My ten cents worth: if your page editor has admin access and can edit widgets, then you can create a widget zone for each of those items and provide an appropriate widget for each if your page editor doesn't have admin access, e.g. they have role editor or author, then they won't be able to edit the widgets to update them; use custom fields on the page. ...


2

There is a difference between the home page and the front page. Since the code uses is_front_page I assume that is what you want, but check the Codex for the difference. I don't know how your theme works, but it looks like the theme rolls several things into the "info bar". The code you posted just checks to see if there is any reason to display that bar. ...


2

Text its just plain text, just as its saved in your db. Wordpress changes line breaks with paragraphs with the function wpautop, through the filter the_content and the_excerpt. If you need to remove the wpautop behavior, you can remove the filter by doing this in your theme's functions.php: remove_filter( 'the_content', 'wpautop' ); remove_filter( ...


2

You can try to make use of filters in query (likely posts_where) to make it look for match between clean value and MySQL REGEXP command (if it fits, didn't use it myself) with your logic, run on raw value.


2

Try this: <?php //Custom header // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' )) && $image[1] >= ...


2

You can add it as an argument: <?php wp_dropdown_categories( 'show_option_none=CHOOSE THE CATEGORY!' ); ?> Reference: wp_dropdown_categories


2

The _n (see Codex) function accepts four arguments. The first two are texts to be translated (the first is singular, the second plural), the third argument is a number (in this case $count). When $count is 1 the first string is used, otherwise the second string is used. So in fact the first instance of $count is only used to determine whether the single / ...


2

If you're looking to remove the actual div with the textwidget class applied to it but not it's content, this is a simple method using jQuery: $('.textwidget').replaceWith($('.textwidget').contents());


2

For singular, one time pieces of content on the home page you might consider using widgets. Register a "sidebar" in your functions file and then call that sidebar into your home template. Drag text widgets into that sidebar and voila. For your feeds, use Posts or custom post types. Header and Footer really depend on what they'd contain.


2

WordPress emulates magic_quotes_gpc and won't be deprecating this for some time due to concerns over plugin security and backward compatibility. To work around this, you need to use stripslashes() or, if you need to strip slashes when data arrives via $_POST, $_GET, $_COOKIE, and $_REQUEST arrays, you can use the WordPress stripslashes_deep() function: ...



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