Archive for February, 2014


WordPress – Custom length excerpt

If you ever need a custom length excerpt in your wordpress site, and want to leave the excerpt length alone for the rest of the site, you can use wp_trim_words on the content to pull out exactly how many words you want the excerpt to be.

In the following example I made a 10 words excerpt, but you can make it any length you want by changing the number.

<?php echo wp_trim_words(get_the_content(), 10); ?>

Permalink » No comments

Strip links in HTML using Dreamweaver

I was putting together some “preview” HTML pages and needed to make sure the links didn’t go anywhere odd.  So I found out how to quickly strip out all the links from an HTML document using Dreamweaver’s regular expressions and find and replace.

It’s pretty easy, just put this in the find field:

<a href='(.*)’>

and this in the replace:

<a href=’#’>

And make sure to select “Use regular expression,” just like this:

strip_links

Permalink » No comments

Hey death, Moshimo

A friend hooked me up with a way to play Japanese games, it’s pretty nice Japanese practice :) The instructions are over here.

I started off with a game called “Hey death, Moshimo” it’s a free download based on RPG Maker.  So you’ll need both the game and RPG Maker VX Ace RTP to play.

5086

The game is a little weird, but I liked it a lot.  You start out in a room, and you really don’t go anywhere else.  You can run around and clicking on different objects in the room and almost immediately you’ll get and “ending”  but you’ll be able to start where you left off, which is kinda unique.

Spoilers after this!

After a while a diary showed up after I answered the phone.  It was about a girl (akari I’m assuming)  Who was waiting for mike-san.  They were planning to get together for their 6th year anniversary, but mike-san got busy with work and had to postpone it.  The last entry describers her as being happy that his plane will be arriving tomorrow and she’ll go pick him up.

That will give you an ending, and starting after that the TV will flash white.  If you go up to the TV it will tell you a news report, that a girl was ran over by a car today and died in a hospital that afternoon.  It then tells you that news report is a month old, and you get another ending.

Then when you start up again you’ll hear a pounding at the door, lave the room and a scary ghost appears!!  And it will give you three options: deny that it exists; embrace it; or search the room.  The last one is a little odd…but I choose to embrace the monster.  Then there’s a sweet little cut scene and the evil monster turns into a cute girl.  Happy end, awww :)

Permalink » No comments

Ruby, Haml, and SASS in Dreamweaver CS6

Call me a dinosaur, but I’m still chugging away with Dreamweaver.  I can’t pull myself away from the lovely site management and built in FTP features :)

But Dreamweaver lacks support for Ruby, and it’s friends HAML and SASS :(  I’ve never gotten HAML and SASS to work 100% with highlighting, but there’s a nice little extension for getting ruby highlighting called “Rubyweaver.”

How can download Rubyweaver from github, https://github.com/cannikin/rubyweaver.  At this time it doesn’t have installation instructions, but I just sent a pull request containing them, so they will probably be there now :)  It’s pretty simple, just make certain not to skip the “Run as administrator” step, or the installation won’t take.

Now you can open up ruby files and they’ll have some lovely color coding :)  Next, is to make dreamweaver open SASS and HAML files.  There are some tricky steps to get syntax highlighting for SASS, but everything I’ve tried just makes everything pink.  That only really works if you write SASS the same way as you would write CSS.  (I indent my SASS – no curly braces for me!)

In Dreamweaver

  • Go to file>preferences
  • Select File Types/Editors
  • In “Open in code view” add ” .haml .sass”

In notepad

  • Go to C:\Users\~Your Username~\AppData\Roaming\Adobe\Dreamweaver CS6\en_US\Configuration
  • open Extensions.txt
  • on the first line add in ,RB,HAML,SASS
  • change
    HTM,HTML,HTA,HTC,XHTML:HTML Documents
    to
    HTM,HTML,HTA,HTC,XHTML,HAML:HTML Documents
  • and then change
    CSS: Style Sheets
    to
    CSS,SASS:Style Sheets
  • You can also add any other extensions you need to wherever you want.

Now they’ll open up in code view and you’ll be able to search whole folders as well. :)

Permalink » No comments

Omit posts with a custom field from WordPress

It took me a while to track this down so I thought I’d post about it.

In a recent project I had the need to omit posts from a WordPress query based on if they had a custom field set to them.

It’s pretty simple once you know how it’s done, imaging you want the ability to remove posts from the homepage by hand.  If you used the custom field name of “hide-me” your query would look like this:

1
query_posts('meta_key=hide-me&meta_compare=NOT EXISTS&meta_value=test');

For “meta_key=hide-me” the hide-me can be whatever custom field you like, and for “meta_value=test” it doesn’t matter at all what you set for “test.”  That’s a little odd, but WordPress needs to have that value, but since you’re only checking weather or not the custom field is there the value doesn’t matter.

The tricky bit it is “meta_compare=NOT EXISTS”  and took a bit of digging to find that.  I had to dig through the documentation of WP_Query to track it down.  It also says that it won’t work for query_posts, but that bit might be out of date, at least for WordPress 3.7.1.  That basically just tell WordPress to check if that custom field doesn’t exist.

It’s pretty easy to use, but I wasn’t able to find a simple write-up on it anywhere and took me a bit of trial and error to get going.  So I thought I’d share :)

Permalink » No comments