How To Fix Archives - Page 4 of 12 - Digital Tool Factory blog How To Fix Archives - Page 4 of 12 - Digital Tool Factory blog

The Digital Tool Factory Blog

How to order a custom WordPress Post Type by a custom numeric field

So, you need to order a custom WordPress Post Type by a custom numeric field – how?

The Problem

You have a WordPress custom post types, and you need to order by a custom numeric field – how do you do that?

The Cause

You would think that it would be relatively simple, for example the below should work

<?php $loop = new WP_Query( array( 'post_type' => 'staff-member',
'posts_per_page' => 100, 'order' => 'ASC', 'orderby'	=>
'meta_value', 'meta_key' 	=> 'OrderByField','type' => 'numeric' ) ); ?>

But ‘OrderByField’ is treated as a text field, and the number 10, comes after 1, not 2.

The Solution

Use the magic keyword meta_value_num, so your WP_Query would look like this

<?php $loop = new WP_Query( array( 'post_type' => 'staff-member',
'posts_per_page' => 100, 'order' => 'ASC', 'orderby'	=>
'meta_value_num', 'meta_key' => 'StaffOrderBy',
'type' => 'numeric' ) ); ?>
the _num makes all the difference - WordPress will treat it as a numeric field.

04
Dec 12


Written By Steve French

 

How to fix problems with asp.net mvc 4 javascript bundling

The Problem

You are using the new JavaScript bundling and minification features in asp.net mvc 4, and some of your JavaScript files are not being included

The Cause

The minification process – in it’s strange wisdom, does not include .min files when it bundles.  Therefore something like

.Include(“~/Scripts/jHtmlArea-0.7.0.min.js”)

will not be included, leading to JavaScript errors.

The Solution

Just use the non-minified version of the script file –

.Include(“~/Scripts/jHtmlArea-0.7.0.js”)

will work just fine – it seems that the asp.net mvc bundler prefers to do it’s own minification.


04
Dec 12


Written By Steve French

 

How to fix problems with WordPress taxonomy permalinks

The Problem

You are attempting to use WordPress taxonomies to create custom permalinks, and all you get are 404 errors.

To clarify, I was trying to use the taxonomies purely to maniplate custom page types and their permalinks, to create something like http://Domain.com/SummerCrops/Tomatos where SummerCrops is my custom taxonomy, and Tomatos is a page name

The Cause

WordPress is finicky about permalink syntax, specifically the difference between /%PostName%/ and /%PageName%/ – so for example a custom permalink structure of /%content%/%postname%/ would not work ,whereas  /%content%/%pagename%/ will.  Practically all online documentation refers to posts, not pages.

The Solution

Just use the custom permalink of /%content%/%pagename%/ and everything will be perfect.


20
Nov 12


Written By Steve French

 

How to fix problems with ReSharper LINQ Intellisense

The Problem

Resharper’s Intellisense, while generally awesome, does not find navigation properties in Linq statements

The Cause:

No Idea

The Solution

Switch back to Visual Studio 2012’s Intellisense, then go to Resharper > Options > Environment > General and make sure that the “Store Caches in the System Temp Folder

Close and Reopen Visual Studio 2012 and everything should be working well.


18
Oct 12


Written By Steve French

 

How to fix problems with WordPress Front Pages not showing the proper template

The Problem

You are using a custom post type as the front page, and for no obvious reason it will not display in the custom template your wrote

The Cause

The front page always uses the font-page.php template in your theme, and if front-page.php is not present, then it will use the page.php template file.

The Solution

Create a front-page.php template file – it’s quite simple with that bit of missing information.


17
Oct 12


Written By Steve French

 

How to change the number of comments visible in the WordPress Admin

The Problem

'hiding in plain sight' photo (c) 2008, Kai Schreiber - license: http://creativecommons.org/licenses/by-sa/2.0/You have an old, established blog, and you left comment spam protection off (a tragic mistake).   I did this recently with one of my personal blogs and in very little time I had 15,000 comments pending in my spam folder.  I set about to delete the spam but found that I could only delete 20 at a time.  How could I change the number of comments visible in the WordPress Admin ? I looked everywhere in the option and settings and could not find anywhere to have the wordpress admin display more.  I even looked in the actual php files and could not find anything

The Cause

The option is actually hiding in plain sight.

The Solution

Click on “Screen Option” in the upper right” and in the box below “Show On Screen” and enter in however many you want to display.


10
Sep 12


Written By Steve French

 

How to fix “type or namespace services does not exist in the namespace system.data” problem

The Problem

'Data Model Template - Excel spreadsheet' photo (c) 2009, IvanWalsh.com - license: http://creativecommons.org/licenses/by/2.0/
the cause is that you are using .net 4.0 code in a 4.5 project, to solve, just go to add reference, search type in system.data.services, et al and add them manuallyYou create a new .net framework 4.5 solution in Visual Studio 2012 and you start to use some sample code from the Windows Azure Data Market. You attempt to compile and you get the “type or namespace services does not exist in the namespace system.data” and your service will not compile.

The Cause

For whatever reason, System.Data.Services does not come over automatically when you create the solution. It seems that System.Data is in .net 4.5, but System.Data.Services is .net 4.0. The fix for this was so easy I never bothered to look into it further.

The Solution

Just right click on the solution, and “Add Reference”, and then type in System.Data.Services, it will appear and just select it. Bada bing, problem solved.


08
Aug 12


Written By Steve French

 

How to fix the “Unable to launch the visual studio development server because port 9452 is in use” error

The Problem

You are coding away, Visual Studio locks up for one of it’s many reasons, and reopen your project and run it again. You then get the “Unable to launch the visual studio development server because port 9452 is in use” error

The Cause

When Visual Studio crashed, the Web Server did not, so basically it thinks you are trying to run two instances at the same time, which is not allowed.

The Solution

Open up the process manager, go to the Processes tab, and select “WebDev.WebServer40.exe” and click “End Process”. Then try running your project again. Visual Studio will now start the project fresh and the problem should go away.


01
Aug 12


Written By Steve French

 

How to fix problems with Ajax Page Caching in asp.net mvc 4

The Problem

'Error' photo (c) 2008, Nick Webb - license: http://creativecommons.org/licenses/by/2.0/You’re using the otherwise awesome ASP.net MVC 4 and you can use an ajax function once, via the @Ajax.ActionLink tool, but you try it again, and it does nothing.

The Cause

For whatever reason the browser thinks it is a cache page and pulls it from the cache – I’m not 100% sure of this.

The Solution

Just add a DateTime.Now as a parameter, this forces the browser to send the data every time.


28
Jun 12


Written By Steve French

 

How to fix the “Handler “dotless” has a bad module “ManagedPipelineHandler” in its module list” problem

The Problem

'Software Bugs' photo (c) 2006, Martin Maciaszek - license: http://creativecommons.org/licenses/by/2.0/You are working away, using the wonderful dotless plugin for IIS, and also taking advantage of the great features of the Less Css System.  Then, for no good reason, your .less file stops loading.  You create all sorts of new Mime types and reboot the server, but nothing seems to work, how do you fix it?

The Cause

Upon closer examination, you uncover the following error

HTTP Error 500.21 – Internal Server Error
Handler “dotless” has a bad module “ManagedPipelineHandler” in its module list

even though you have not changed anything about dotless.

The Solution

At some point the application pool has changed.  Just change it back to a more recent version (I was using a custom application pool) and the problem goes away.


27
Jun 12


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.