07
07
16



Creating a parent-child relationship in WordPress is not difficult, but when the parent and the children are of a different content type, creating the relationship can be a bit tricky. Even though there are several ways of accomplishing this, after the cut, I present the way I solve it for my projects.

WordPress treats all content types the same way (as posts) and stores each object/post of a content type in the same database table, under the post type attribute. If you have access to your WordPress database, you can see that posts are for instance stored with post type “post” while pages are stored with the post type “page”.


Read article

06
07
16



Lately I’ve found myself favoring monospace fonts and the new design of this website as of november 2015, was sporting the fantastic Roboto Mono from Google Fonts. I really liked Roboto Mono, but felt that I needed something with more personality. A couple of days ago I found Rational TW and I fell suddenly in love.

208331

After playing with it Rational TW a bit in Typecast, I decided that I would use it for this blog as it pairs beautifully with Work Sans, here used for the headings.

16
06
16



A little note to self: StringBuilder a = new StringBuilder(); is the same as var b = new StringBuilder();, but you can’t write var c; c = new StringBuilder();

In that case you must write:

StringBuilder c;
c = new StringBuilder();

Because the compilator needs to know the data type at compile time.

01
01
16



Well, the title of this article is somewhat misleading. What the code below accomplishes is to display either the_content() or the_excerpt() depending on whether you wrote an excerpt for it or not. Let’s say we have a long post, then we want to display an excerpt of that post, together with a “read more”-link. If the article is short, then we wouldn’t need to write an excerpt for it, so we would want to display the entire post.

 <?php
	if (empty($post->post_excerpt)) {
		the_content();
	}
	else {
		the_excerpt();
	}
?>        

The way this works is if you add content to the excerpt field when you write a post, then WordPress will show it, if you do not, then WordPress will show the whole post. Does that make any sense?
The code above should be applied within the loop, in the index.php-file.

This is more or less the way the “more” button available in WordPress works, with the difference that the excerpt lets you decide completely on what is shown on your index, whilst “more” cuts your post right after where you placed it.

The next step I am going to code is an automatic way of displaying either the_content() or the_excerpt() based on word/characters count. Stay tuned!

UPDATE: I found this article by Justin Tadlock for another way of doing the same as I did, without editing theme files, only the functions one. Mind you, this article is from 2008 and I have not tested it.

01
01
16



Sometimes, we need to be able to display static HTML pages in a ASP .NET MVC project. In order to do so we have to follow a few easy steps. The order of the steps is actually irrelevant, I’ve just listed them up without any particular order.

In the RouteConfig.cs file (usually, within the App_Start folder), paste the following:

routes.MapRoute(
    name: "StaticHTMLPages",
    url: "{page}.html",
    defaults: new { controller = "Page", action = "StaticHtmlPage", page = UrlParameter.Optional }
);

Read article