Tag Info

Hot answers tagged

26

here's what we did yesterday on a client site that we were having this exact problem with... I created a quick filter as a plugin and activated it. <?php /* Plugin Name: Image P tag remover Description: Plugin to remove p tags from around images in content outputting, after WP autop filter has added them. (oh the irony) Version: 1.0 Author: Fublo Ltd ...


12

Basically you need to make WordPress treat img like block-level element for the purpose of formatting. Such elements are hardcoded in wpautop() and list is unfortunately not filtered. What I would do is: Fork wpautop() under different name. Add img to regexp in $allblocks variable. Remove wpautop from the_content filter. Add your forked version to ...


10

The best way is without plugin - i set WP3.0 with multisite; the first blog is a dummy to rewrite the uesers to right blog with his language, a small script in the theme to rewirte ro the right language; i see in the browser-language of the users and rewrite; the second is the default blog, the third blog is another blog and so on - olso it is possible to ...


8

Not exactly sure what you are trying to accomplish, but it looks like you are trying to prepend something to the beginning of the_content. Try this: add_filter('the_content', 'se24265_my_function'); function se24265_my_function( $content ) { $write = 'hello world'; $new_content = $write . $content; return $new_content; } Most filters will ...


7

I always use the Theme Unit Test that Theme Reviewers use to evaluate themes for the Repo. It's got pretty much everything you need to style/worry about. And if I need to create batch content in a different way, then I use WP Dummy Content


7

Caution: very mac/linux/unix centric thoughts ahead. Includes a lot of command line fu. Put All the Code Under Version Control I like git. Mark Jaquith has some good suggestions on keeping an entire site under version control using git and submodules for the WordPress core. You could also put plugins in as git submodules. The developer end of the team ...


7

You might want to consider creating a Custom Post Type for this product (I assume it's some sort of product), and then adding custom metaboxes, that will store the custom data (specs, features, etc.) as metadata for each Post. Then, your custom template file becomes "single-.php" (e.g. "single-product.php"), and you can structure the markup however you ...


7

Typically you use widgets or custom post types but in reality these solutions can be unfriendly to clients. WordPress still revolves around the idea of a post based loop so doing traditional "content blocks" that you might find in other frameworks can be difficult. Fortunately there are plugins that are pretty good in this area. I recommend checking out ...


6

If it is a strict structure, you might be better off creating a custom post type. You would then store the name in the title field, the image as the featured image, and the "About" would be the main content. If you need extra information, you can use custom fields (with a plugin to style them).


6

Your sites look nothing alike. Open those three links - and there is not a single element that binds all three sites together. Network of sites can benefit from consistent looks. You could use global "about" page that covers all of your activity and not just bits in context of specific site. Consider building landing page that will summarize yourself, your ...


6

Prevent authors from publishing too short content: Here's one idea using a custom post status, for example short: /** * Register a custom 'short' post status * * @see http://wordpress.stackexchange.com/a/159044/26350 */ function wpse_short_post_status() { register_post_status( 'short', array( 'label' => _x( 'Short', ...


5

I just ran into this situation. Here is a function I used to undo wpautop. I might be missing something, but this is a good start: function reverse_wpautop($s) { //remove any new lines already in there $s = str_replace("\n", "", $s); //remove all <p> $s = str_replace("<p>", "", $s); //replace <br /> with \n $s = ...


5

It's not a book but I wrote a "25 Steps to Understand WordPress and it's Terms" about a month ago in response to a question on the LinkedIn WordPress group and maybe copying it here will help? (Maybe I could every take these and turn them into a book for managers complete with screenshots; what do you think?) 25 Steps to Understanding WordPress and it's ...


5

You already got something like this built in: Revisions. // Define the nr of saved revisions in your wp-config.php define( 'WP_POST_REVISIONS', 30 ); You can simply grab them by calling get_posts() with a post_type of revision. To show the difference between two revisions simply use wp_text_diff(). // Example $revisions = get_posts( array( ...


5

You could use a Git hook and post per XML-RPC to WordPress. A Git hook can be any executable file, even PHP. Another option – on GitHub – is to use the email hook: Go to https://github.com/username/projectname/admin/hooks, select Email and send an email to the blog. Enable the Post per email feature.


5

You can use output buffering to accomplish this. Add a high priority hook directly before the template is rendered: add_action('template_redirect', 'foo_buffer_go', 0); function foo_buffer_go(){ ob_start('foo_buffer_callback'); } Add a shutdown hook with an extremely low priority. add_action('shutdown', 'foo_buffer_stop', 1000); function ...


4

Add a meta box to the post editor, similar to the excerpt meta box, and get the content of the meta box in your sidebar. If you want to reuse the same text on different pages create a custom post type sidenotes and add a meta box with a select field to let the author choose the text.


4

In WordPress Dashboard > Settings > Media and fill the field "Full URL path to files" with your other domain. See the screenshot below: EDIT: I thought it would be obvious, but it isn't. Here's what you exactly need to do: You should map your domain to point to: public_html directory, IF it's also your WordPress installation's root directory. ...


4

There were several errors in your code. The biggest was that the function didn't even have a closing bracket, but we can probably assume that was just not copied into your post, otherwise nothing would have been working for you. This is a filter on the content right? It looks like you want to append these shares after your post content. If that's the case ...


4

I sometimes use Custom fields Template : http://wordpress.org/extend/plugins/custom-field-template/ You can attribute a type to your field (wysiwyg, list, image...)


4

If I read correctly, it's already a WP-multi site right? Maybe: create one main theme that will be used on all the sites create a child theme for each site that varies the color, or logo, or whatever to make it distinct. Use common widgets to pull in twitter feeds, etc. To increase the cross pollination of posts, use a special category that corresponds to ...


4

Also, from a purely PHP point of view, the function str_replace returns a new string, and should be assigned to a different string variable. The examples are like below. See the PHP manual. function content_magic($content) { $new_content = str_replace('<div id="content">','<div id="new_content">',$content); return $new_content; } ...


4

Theme demos, especially commercial ones, do not display out-of-the-box state of it. They are hand crafted and fine-tuned setups designed to sell (or at least convince for free ones). The official set of content that is typically used for quickly reviewing, evaluating and testing theme is called Theme Unit Test data. There are also unofficial sets, such as ...


4

The internal implementation details of that feature are of questionable sanity. If you take a look at said featured-content.php template you would see that it get posts from twentyfourteen_get_featured_posts() however the only thing that function has is twentyfourteen_get_featured_posts filter from quick look at which in peculiar fashion nothing is ...


3

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


3

The alternative way. Problem with @david.binda solution is that: you have to hardcoding a lot of things, (manually write db credientials, table prefix..) You cannot use content filter (so if you have shortcode in your page, you will see some [something] instead of desired content..) sure you can load wordpress environment, but... Just yesterday I wrote ...


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

The error message you get means that a function has been hooked without a valid callback. In other words it means that somewhere in your theme or in a plugin a function has been set but it's not "hooked" properly. See the example : function add_post_content() //<- the callback { // blabla } add_action( 'hook_name', 'wrong_name_function' );//<- ...


3

You are under a fundamentally wrong assumption: The content you input via the administrative back-end does not live in a file, but in the database, specifically in the wp_posts table. Do not be misguided by the table's name, a "page" is technically a post of type page. If you attempted to find the content you created via your "hosting file manager", it is ...



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