Archive

Archive for the ‘CMS’ Category

WordPress Maintenance Mode Without a Plugin

August 2nd, 2011 No comments

 

 

Source: http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/

 

Posts in This Series

Every so often someone asks a question in the WordPress IRC channel that sparks my interest, and in this case the core maintenance mode functionality was one of those questions. I’ve known for sometime that WordPress has it’s own maintenance mode functionality since core upgrades were added, however I had never really looked into the functionality. Hooking into this functionality is really quite simple and effective.

Start by creating a file in the root of your WordPress install (on level with wp-settings.php) called .maintenance. Note the preceding dot like a .htaccess file; in Linux this is considered a hidden file. In this file add the following code:

<?php $upgrading = time(); ?>

This code will basically cause the maintenance page to display until you remove the .maintenance file. In wp-settings.php there are 2 checks to see if it should display the maintenance page. First, it makes sure that the .maintenance file exists. Second, it checks that the current time minus the time specified by the $upgrading variable is less than 10 minutes. Using the code above will insure that it is always less than 10 minutes since time() - time() == 0. If you want it to display for a certain period of time you would want to use:

<?php $upgrading = 1234567890; ?>

For your usage you would want to replace 1234567890 with the unix formatted timestamp of the time minus 10 minutes at which you want the maintenance page to stop displaying.

For example if I wanted the maintenance page to stop displaying at November 14, 2013 at 20:13:00, I would really set the $upgrading variable to November 14, 2013 at 20:03:00. Notice the 03 instead of 13. In unix time this would look like 1384459380. And the code needed for the .maintenance file would be:

<?php $upgrading = 1384459380; ?>

Take note that if you use a specific time in the .maintenance file and you do not remove the .maintenance file, your users will see your site and not be affected, however in the admin you will see a notice stating, “An automated WordPress update has failed to complete – please attempt the update again now.” Deleting the .maintenance file will remove this notice.

I’m sure that this functionality could be wrapped in a plugin, or even better an option added to the core code in the admin. However, I am happy with just manually creating the file.

For information on modifying or styling the maintenance page see WordPress Maintenance Mode Without a Plugin Part 2.

Categories: CMS Tags: ,

WordPress 2.9

December 19th, 2009 No comments

 

Source: WordPress Blog

 

I want to make you mine, all the time… oh wait. Hello. I’m here on behalf of the entire WordPress development team and community to announce the immediate availability of WordPress version 2.9 “Carmen” named in honor of magical jazz vocalist Carmen McRae (whom we’ve added to our Last.fm WP release station). You can upgrade easily from your Dashboard by going to Tools > Upgrade, or you can download from WordPress.org. And of course, it wouldn’t be a major release without a short video summarizing some of the cool things about the new version:

 

 

The coolest new stuff from a user point of view is:

  1. Global undo/”trash” feature, which means that if you accidentally delete a post or comment you can bring it back from the grave (i.e., the Trash). This also eliminates those annoying “are you sure” messages we used to have on every delete.
  2. Built-in image editor allows you to crop, edit, rotate, flip, and scale your images to show them who’s boss. This is the first wave of our many planned media-handling improvements.
  3. Batch plugin update and compatibility checking, which means you can update 10 plugins at once, versus having to do multiple clicks for each one, and we’re using the new compatibility data from the plugins directory to give you a better idea of whether your plugins are compatible with new releases of WordPress. This should take the fear and hassle out of upgrading.
  4. Easier video embeds that allow you to just paste a URL on its own line and have it magically turn it into the proper embed code, with Oembed support for YouTube, Daily Motion, Blip.tv, Flickr, Hulu, Viddler, Qik, Revision3, Scribd, Google Video, Photobucket, PollDaddy, and WordPress.tv (and more in the next release).

2.9 provides the smoothest ride yet because of a number of improvements under the hood and more subtle improvements you’ll begin to appreciate once you’ve been around the block a few times. Here’s just a sampling:

  • We now have rel=canonical support for better SEO.
  • There is automatic database optimization support, which you can enable in your wp-config.php file by adding define('WP_ALLOW_REPAIR', true);.
  • Themes can register “post thumbnails” which allow them to attach an image to the post, especially useful for magazine-style themes.
  • A new commentmeta table that allows arbitrary key/value pairs to be attached to comments, just like posts, so you can now expand greatly what you can do in the comment framework.
  • Custom post types have been upgraded with better API support so you can juggle more types than just post, page, and attachment. (More of this planned for 3.0.)
  • You can set custom theme directories, so a plugin can register a theme to be bundled with it or you can have multiple shared theme directories on your server.
  • We’ve upgraded TinyMCE WYSIWYG editing and Simplepie.
  • Sidebars can now have descriptions so it’s more obvious what and where they do what they do.
  • Specify category templates not just by ID, like before, but by slug, which will make it easier for theme developers to do custom things with categories — like post types!
  • Registration and profiles are now extensible to allow you to collect things more easily, like a user’s Twitter account or any other fields you can imagine.
  • The XML-RPC API has been extended to allow changing the user registration option. We fixed some Atom API attachment issues.
  • Create custom galleries with the new include and exclude attributes that allow you to pull attachments from any post, not just the current one.
  • When you’re editing files in the theme and plugin editors it remembers your location and takes you back to that line after you save. (Thank goodness!!!)
  • The Press This bookmarklet has been improved and is faster than ever; give it a try for on-the-fly blogging from wherever you are on the internet.
  • Custom taxonomies are now included in the WXR export file and imported correctly.
  • Better hooks and filters for excerpts, smilies, HTTP requests, user profiles, author links, taxonomies, SSL support, tag clouds, query_posts and WP_Query

All of this and more is reflected in the over 500 tickets, bugs, and enhancements that WP developers in this release cycle.

This release included code from over 140 contributors, here’s everyone we were able to identify: aaroncampbell (Aaron Campbell), abackstrom (Adam Backstrom), aldenta (John Ford), alexkingorg (Alex King), [amilanov], antonylesuisse (Antony Lesuisse), apeatling (Andy Peatling), apokalyptik (Demitrious Kelly), arena (André Renaut), batmoo (Mohammad Jangda), Ben Dunkle, BenBE1987, Benjamin Flesch, bookchiq (Sarah Lewis), brianwhite, c0nstruct, caesarsgrunt (Caesar Schinas), CalebKniffen (Caleb Kniffen), chrisbliss18, chrisscott (Chris Scott), christoph179, coffee2code (Scott Reilly), [cross country flight], Curioso, davecpage (Dave Page), dcole07 (Dan Cole), dd32 (Dion Hulse), demetris (???????? ???????), Denis-de-Bernardy, dj-wp, dwright, eddieringle (Eddie Ringle), error (Michael Hampton), ewestp, fabifott, filosofo (Austin Matzko), greenshady (Justin Tadlock), gsnedders/link92 (Geoffrey Sneddon), hailin (Hailin Wu), hakre, hanilovesme, Harald Nesland, harrym, holizz (Tom Adams), ikonst, jacobsantos (Jacob Santos), janeforshort (Jane Wells), jamescollins (James Collins), jdub (Jeff Waugh), jeff_ (Jean-François “Jeff” VIAL), jeremyclarke (Jeremy Clarke), JeremyVisser (Jeremy Visser), jikamens, jmulley, Joern_W, johanee (Johan Eenfeldt), johnbillion (John Blackbourn), johnjamesjacoby (John James Jacoby), johnjosephbachir (John Joseph Bachir), JonathanRogers, joostdevalk (Joost de Valk), Jose Carlos Norte, josephscott (Joseph Scott), junsuijin, kevinB (Kevin Behrens), kometbomb, lilyfan (IKEDA Yuriko), [lostinlafayette], madhyde, MattyRob, mdawaffe (Michael Adams), Mittineague, miqrogroove, morfiusx, mrmist (David McFarlane), mtdewvirus (Nick Momrik), mysz, nacin (Andrew Nacin), nanochrome, nao (Naoko McCracken), nathanrice (Nathan Rice), nbachiyski (??????? ????????), niallkennedy (Niall Kennedy), nickohrn (Nick Ohrn), ninjaWR (Ryan Murphy), noel (Noël Jackson), Otto42 (Samuel Wood), pairg, peaceablewhale (Franklin Tse), prettyboymp (Michael Pretty), ProDevStudio, ramiy, redsweater (Daniel Jalkut), ruslany, sambauers (Sam Bauers), scribu, Sewar, Simek, simonwheatley (Simon Wheatley), sirzooro (Daniel Fru?y?ski), sivel (Matt Martz), skeltoac (Andy Skelton), snakefoot, stephanreiter (Stephan Reiter), strider72 (Stephen Rider), taco1991, takayukister (Takayuki Miyoshi), tellyworth, tenpura, usermrpapa, utkarsh, Viper007Bond, vladimir_kolesnikov (Vladimir Kolesnikov), VoxPelli (Pelle Wessman), [voyou1], wahgnube, waltervos, westonruter (Weston Ruter), wnorris (Will Norris), xenlab (Eric Marden), yoavf (Yoav Farhi). Wowza!

2.9 has been an exciting development cycle, and I must say it has whetted our appetite for 3.0, which is coming next (probably this spring) and will include at the very least the merge of MU with the WordPress core, and a new default theme. We can’t wait to start working on it.

Categories: CMS Tags:

WordPress 2.8

June 11th, 2009 No comments

 

Source: Wprdpress Blog

 

The latest and greatest version of WordPress, version 2.8 “Baker,” is immediately available for download. 2.8 represents a nice fit and finish release for WordPress with improvements to themes, widgets, taxonomies, and overall speed. We also fixed over 790 bugs. This release is named in honor of noted trumpeter and vocalist Chet Baker. Here’s a quick video overview of everything in the new release:

 

 

The first thing you’ll notice is that visually 2.8 feels a lot like 2.7, just with some minor tweaks here and there. However once you’ll dig in you’ll begin to appreciate the changes.

Major New Improvements

First and foremost, 2.8 is way faster to use. We’ve changed the way WordPress does style and scripting.

The core and plugin updaters in previous versions of WordPress have been such a success we decided to bring the same to themes. You can now browse the entire theme directory and install a theme with one click from the comfort of your WordPress dashboard.

If you make edits or tweaks to themes or plugins from your dashboard, you’ll appreciate the new CodePress editor which gives syntax highlighting to the previously-plain editor. Also there is now contextual documentation for the functions in the file you’re editing linked right below the editor.

If you were ever frustrated with widgets before, this release should be your savior. We’ve completely redesigned the widgets interface (which we didn’t have time to in 2.7) to allow you to do things like edit widgets on the fly, have multiple copies of the same widget, drag and drop widgets between sidebars, and save inactive widgets so you don’t lose all their settings. Developers now have access to a much cleaner and robust API for creating widgets as well.

Finally you should explore the new Screen Options on every page. It’s the tab in the top right. Now, for example, if you have a wide monitor you could set up your dashboard to have four columns of widgets instead of the two it has by default. On other pages you can change how many items show per page.

And Even More

You can read the full list of over 180 new features, changes, upgrades, and improvements on the Codex. The list is exhausting!

The Future

We’re already thinking hard about the next versions, 2.9 and 3.0. Keep an eye out for improved media handling, better dependency checking, versioning of templates and themes, and of course the fabled merging of WordPress and MU announced at WordCamp San Francisco two weeks ago.

Categories: CMS Tags:

Using Custom Fields in Worpress

March 17th, 2009 No comments

 

Source: http://codex.wordpress.org/Using_Custom_Fields

 

WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can include bits of information such as:

  • Mood: Happy
  • Currently Reading: Cinderella
  • Listening To: Rock Around the Clock
  • Weather: Hot and humid

With some extra coding, it is possible to achieve more complex actions, such as using the metadata to store an expiration date for a post.

Meta-data is handled with key/value pairs. The key is the name of the meta-data element. The value is the information that will appear in the meta-data list on each individual post that the information is associated with.

Keys can be used more than once per post. For example, if you were reading two different books (perhaps a technical book at work and a fiction at home), you could create a "reading" key and use it twice on the same post, once for each book.

Here is an example of what this information might look like on your post:

Currently Reading: Calvin and Hobbes

Today’s Mood: Jolly and Happy

Usage

Based upon our example above, let’s put this into action. We’ll add two custom fields, one called "Currently Reading" and the other "Today’s Mood". The following instructions will demonstrate how to add this information to a post using Custom Fields.

  1. After you have written your post, scroll down to the area titled Custom Fields.
  2. To create a new Custom Field called "Currently Reading", enter the text "Currently Reading" (without the quotes) in the text entry field titled Key.
  3. The newly created Key should now be assigned a Value, which in our case is the name of the book currently being read, "Calvin and Hobbes". Type "Calvin and Hobbes" in the Value field, again without the quotes.
  4. Click Add Custom Field button to save this custom information for that post.

To add your "Today’s Mood", repeat the process and add "Today’s Mood" to the key and a description of your mood in the value text boxes and click SAVE to save this information with the post.

On your next post, you can add a new book and mood to your meta-data. In the Custom Fields section, the Key will now feature a pull down list with the previously entered Custom Fields. Choose "Currently Reading" and then enter the new book you are reading in the value. Click Add Custom Field and then repeat the process to add "Today’s Mood".

You only need to create a new "KEY" once, after which you can assign a value to that key for every post, if you so desire. You can also assign more than one Value to a key, for a post. This will come in handy for people who read more than one book at a time.

Displaying Custom Fields

With a Custom Field added to the post, it’s time to display your books and mood to the world. To display the Custom Fields for each post, use the the_meta() template tag. The tag must be put within The Loop in order to work. Many people add the_meta() template tag to the end of their post or in their Post Meta Data Section. Here is a basic example of using the tag:

<?php the_meta(); ?>

It might look like this in the source code:

<ul class='post-meta'>
<li><span class='post-meta-key'>Curently Reading:</span> Calvin and Hobbes</li>
<li><span class='post-meta-key'>Today's Mood:</span> Jolly and Happy</li>
</ul>

The template tag automatically puts the entire meta-data into a CSS style called post-meta. The key is in a span called post-meta-key so you can style it in your style sheet. All of this is showcased in an unordered list.

To customize the look of the post-meta list, change the characteristics in your style sheet. For instance, let’s add some style to our example from the top. The style sheet elements would look like this:

.post-meta {font-variant: small-caps; color: maroon; }
.post-meta-key {color: green; font-weight: bold; font-size: 110%; }
  • Currently Reading: Calvin and Hobbes
  • Today’s Mood: Jolly and Happy

There are also many WordPress Plugins in the Official WordPress Plugin Directory that add some nice features to the job of displaying meta tags. A search for Custom Field plugins at Google should help you find even more.

Advanced Techniques for Custom Fields

The following are more advanced techniques for getting and customizing meta-data and custom fields.

Getting Custom Fields

To fetch meta values use the get_post_meta() function:

 get_post_meta($post_id, $key, $single);
  • $post_id is the ID of the post you want the meta values for. Use $post->ID to get a post’s ID.
  • $key is a string containing the name of the meta value you want.
  • $single can either be true or false. If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields.

Implementation Details

The PostMeta information is stored in a new table, $wpdb->postmeta. This table has four fields:

meta_id: A unique id for each entry
post_id: The ID of the post for this metadata
meta_key: The name of the ‘key’
meta_value: The value associated with the key

The values from this table are pulled into a structured multi-dimensional array called $post_meta_cache, just after the $posts array is fetched in wp-blog-header.php. This variable will only contain values for the list of posts fetched for the current page build. The structure of the array will look something like this:

 [
   postid1 => [
     [
       key1 => [val1, val2, ...],
       key2 => [val1, val2, ...],
       ...
     ],
   postid2 => [ ... ],
   ...
 ]

So, if you wanted to fetch the "reading" values from post number 256, you use this PHP code:

 // Fetch an array of values for what I'm reading:
 $readinglist = $post_meta_cache[256]['reading'];
Don’t forget that $readinglist will be an array, not a single value.
As of WordPress 2.1, $post_meta_cache isn’t populated anymore. Get the meta values through the functions mentioned below

PostMeta Functions

Internal Functions

These functions are intended for use inside The Loop, and all return arrays.

get_post_custom()
Get all key/value data for the current post.
get_post_custom_keys()
Get a list of all key names for the current post.
get_post_custom_values($key)
Get the list of values for a particular key on the current post.
get_post_meta($post_id, $key, $single = false)
In WP 1.5 and beyond, this function returns the meta information without cache problems. The function requires the post id, the key, and if $single is set to TRUE, it returns only the first result (NOT as an array) for PHP use.
This will output the resulting meta value (notice the addition of "echo"):
<?php $key="mykey"; echo get_post_meta($post->ID, $key, true); ?>

Template Functions

At the time of this writing, there is only one template function.

the_meta()
Echoes an unordered list containing the current post’s meta-data with a class for the UL as post-meta and the LI as post-meta-key.

We expect that independent developers will come up with many interesting uses for post meta-data in the form of plugins. The the_meta() template function is just an extremely basic example.

At this time, you can only add and delete entries. The ability to modify existing entries will be implemented later.

Categories: CMS Tags:

How to post to Joomla 1.5.3 using Windows Live Writer

March 3rd, 2009 No comments

 

Source:

http://carolinaregion.com/2008/07/23/how-to-post-to-joomla-153-using-windows-live-writer/

 

What you need to make WLW post to Joomla:

There are a few requirements to make this work. Of course you’ll need Joomla running on your server and WLW running on your PC. I’m assuming you know that much already. Here’s the rest:

  1. MetaWeblog API plugin for Joomla
    It’s available from: http://joomlacode.org/gf/project/metaweblogapi/frs/
    metaweblogapiplugin-thumb
    Right click on metaweblog.zip and download the zip file to your PC.
  2. RealSimpleDiscovery Plugin for Joomla (RSD)
    It’s available from: http://joomlacode.org/gf/project/rsd/frs/
    realsimplediscovery-thumb
    Right click on rsd.jpb and download the zip file to your PC.
Instructions for Installing the Plugins in your back-end Admin.

Log into your Joomla Admin panel and go to  Extensions –> Install/Uninstall.

adminmenu-thumb

Click “Browse” and then choose the zip files you just uploaded. It doesn’t matter which order you upload them in. You need to upload the MetaWeblog module and the RSD module.

installscreen-thumb

Go to your Plugin Manager and enable the MetaWeblog Plugin and disable the Blogger API that came with your Joomla installation. (Extensions –> Plugin Manager)

meta1-thumb

While you’re there, also enable the RSD plugin. (If it’s hard to find, that’s because it’s called System – Real Simple Discovery (RSD).

meta2-thumb

Enable Web Services

Go to your Global Configuration and choose “yes” to the “Enable Web Services option, which is defaulted to “no.”

This is located under Global Configuration –> System –>System Settings

enableweb-thumb

Now, you’ve finished the Joomla end of the instructions. Now go open Windows Live Writer and let’s create a new Weblog.

Setting up Windows Live Writer to Talk to Joomla
  1. Open WLW and create a new blog account.
  2. Choose “Another Weblog Service” and press next.
  3. Enter your joomla web site address, your username, and your password.

That’s it!

Now, maybe your auto-configuration didn’t work and you need to enter the variables manually. It’s ok, no problem. On the next screen, under type of blog, be sure you choose MetaWeblog API, then enter your XML-RPC url, which will be http://yoursite.com/xmlrpc/index.php.

Now it should work.

Things you should know
  • You MUST be an admin to post on the site automatically. If you are only a Registered User, Editor, or Publisher, the article will still be posted but will await approval by a moderator before being published publicly. If you ‘re not getting any errors, but aren’t seeing your posts, this might be why.
  • You must choose the category for your post, or else Joomla will assign is as “uncategorized” which means it gets treated as a static page. Choose the category from the lower left side of the WLW screen.
    set-thumb
  • If you can’t publish, check to make sure your plugins are enabled properly. If they ARE, and you type http://yoursite.com/xmlrpc/index.php into your browser, you should see something similar to this screen:
    shouldsee-thumb
Categories: CMS Tags:

WordPress 2.7.1

February 11th, 2009 No comments

 

wordpress-logo[2]

WordPress 2.7.1, the first 2.7 maintenance release, is now available.  2.7.1 fixes 68 tickets.  You can automatically upgrade from 2.7 to 2.7.1 via the Tools->Upgrade menu, or you can visit this page or direct download the package and upgrade manually.

Consult the list of fixed tickets and the  full set of changes between 2.7 and 2.7.1 for details.

Categories: CMS, Upgrade Tags:

Customizing the Read More in WordPress

January 31st, 2009 No comments

 

Source: http://codex.wordpress.org/Customizing_the_Read_More

 

If you have set your WordPress site to display post excerpts on the front or home page, you will want visitors to click on the title or a link to encourage them to continue reading your post or article, right? WordPress makes this technique easy, and customizable.

Contents

[hide]

The Excerpt Basics

Excerpts show up on WordPress through two methods. One, by replacing the template tag the_content() with the_excerpt(). Then the explicit excerpt you have entered in the Administration > Write > Post SubPanel will appear, or the first 55 words of the post’s content. Users can then click on the title to continue reading more as you have enticed them with your summary introduction.

The most commonly used method is to keep the_content() template tag and insert a quicktag called more into your post at your desired "cut-off" point.

The quicktags are the little buttons found above the editing window in your Administration > Write > Post SubPanel. They include bold, italic, links, and others, and the famous more. Put your cursor where you want to end the excerpted content of your post and click the more quicktag button. It will insert a code at that point that looks like this:

and I told him that he should get moving or I'd be
on him like a limpet.  He looked at me with shock on
his face and said

<!--more-->

The rest of the post continues, but when viewed on the non-single/non-permalink web page such as archives, categories, front page, and searches, the post is shown as an excerpt to the more point.

Read More Techniques

The parameters within the template tag the_content() are as follows:

<?php the_content('more_link_text', strip_teaser, 'more_file'); ?> 

The more_link_text sets the link text like "Read More". The second one, strip_teaser, sets whether or not the "more" link should be hidden (TRUE) or displayed (FALSE). The default is FALSE, which shows the link text. The last one, more_file, sets the link to the file that the "Read More" should link to, if you want it to be different. By default, it links to the current post file.

To remove the teaser:

  • Change the_content(); in your index.php to (i.e., the second parameter controls this):
the_content('',FALSE,'');>
  • Include <!--noteaser--> in the post text, immediately after the <!--more-->.

Link Jumps to More or Top of Page

By default, when you click on the Read More link, the web page loads and then "jumps" to the spot where the <--more--> tag is set in the post. If you do not want that "jump", you can change the default function of how this works by editing the following line in wp-includes/template-functions-post.php

(NOTE: In WP 2.1 and later, the code is found in wp-includes/post-template.php ).

(NOTE: When you upgrade WordPress, this file will be replaced so make a note of the change so you can change it again after upgrading.):

$output .= ' <a href="'. get_permalink()
. "#more-$id\">$more_link_text</a>";

to

$output .= ' <a href="'. get_permalink()
."\">$more_link_text</a>";

or

$output .= ' <a href="'. get_permalink()
.'">$more_link_text</a>';

Designing the More Tag

Seeing that you know how it works, now look at how we can make this little invitation to continue reading your post be more inviting.

By design, the_content() tag includes a parameter for formatting the <!--more--> content and look, which creates a link to "continue reading" the full post.

By default, it looks like this:

and I told him that he should get moving or I’d be on him like a limpet. He looked at me with shock on his face and said more…

If you want to change the words from more…. to something else, just type in the new words into the tag:

<?php the_content('Read on...'); ?>

Or get more sophisticated and make it fun:

<?php the_content('...on the edge of your seat? Click
here to solve the mystery.'); ?>

You can style the text in the tag, too.

<?php the_content('<span class="moretext">...on the edge of
your seat? Click here to solve the mystery.</span>'); ?>

Then set the moretext class in your style.css style sheet to whatever you want. Here is an example of the style which features bold, italic text that is slightly smaller than the default text and uses the font-variant: small-caps to force the text into small capital letters. :

and I told him that he should get moving or I’d be on him like a limpet. He looked at me with shock on his face and said …On the Edge of Your Seat? Click Here to Solve the Mystery.

Some people do not want the text and prefer to use an extended character or HTML character entity to move the reader on to the full post.

<?php the_content('&raquo; &raquo; &raquo; &raquo;'); ?>

Would look like this:

and I told him that he should get moving or I’d be on him like a limpet. He looked at me with shock on his face and said » » » »

There is another parameter in the_content() template tag which will include the title of the post in the more text. Through the use of the_title() tag, the title of the article is included:

<?php the_content("...continue reading the story
called " . get_the_title('', '', false)); ?>

and I told him that he should get moving or I’d be on him like a limpet. He looked at me with shock on his face and said …continue reading the story called A Tale That Must Be Told

Having a custom text for each post

Although the_content() is usually called from the template with a standard text as described above, it is possible to have an individual text for certain posts. In the visual editor, simply write <!--more Your custom text -->.

So, you may have something like this:

<!--more But wait, there's more! -->

Adding An Image

The design possibilities with CSS are practically unlimited, and WordPress allows you to use images in many of their Template Tags, including the more tag. To add an image, there are two ways to do it. Begin with the most simple — listing it in the_content() template tag.

This examples features the image of a leaf after the "Read More" text.

<?php the_content('Read more...<img src="/images/leaf.gif"
alt="read more" title="Read more..." />'); ?>

Notice that the code uses an ALT and TITLE in the image tag. This is in compliance with accessibility and web standards, since the image is both an image and a link. Here is what it might look like.

and I told him that he should get moving or I’d be on him like a limpet. He looked at me with shock on his face and said Read More… leaf

You could even add a style to the image and more tag, as mentioned above, to style it even more. To use the image without the "Read More" text, just delete the text.

The second example uses the CSS background image. We have described how to use style classes in the above examples. This is a little tricker. The container’s style must be set to allow the background image to show out from behind the text. If you were to use the above example as a background image, the style.css style sheet for this might look like this:

.moretext {
   width: 100px;
   height: 45px;
   background:url(/images/leaf.gif) no-repeat right middle;
   padding: 10px 50px 15px 5px}

The 50px padding against the right margin should make sure the text is pushed over away from the image as to not overlap it. The height ensures that the container will expand wide enough so the image is visible within the container, since a background image isn’t "really there" and can not push against the container’s borders. You may have to experiment with this to fit the size and shape of your own image.

You have gotten the basics. From here, it is up to your imagination.

Read More is ignored on front (home) page

Please remember that on the home page ( is_home() == TRUE ), the <!--More--> tag is ignored unless you turn on it again using the following code:

global $more;
$more = 0;

See More tag ignored on home page forum topic.

Categories: CMS, Miscellaneous Tags: