Skip to content

Gordon French

The ramblings of a php developer / gearhead / used car dealer

Categories

  • 1946/46 Chevrolet
  • 1976 SWB 4×4 Chevy
  • 1989 Mazda B2200
  • Cars & Trucks
  • Datsun 620
  • Enslaved – Nissan D21
  • Programming
  • Wordpress

Quick Links

  • 620
  • 1946
  • Authors
  • B2200
  • bagged
  • Blog
  • bodydrop
  • Breakpoint
  • Chevrolet
  • Chevy
  • classes
  • cms
  • content managment system
  • d21
  • Database Issues
  • Datsun
  • dynamic color
  • dynamiccolor
  • Excerpt
  • Frontpage
  • Global Community
  • Google
  • hardbody
  • Mazda
  • Meta Data
  • minitruck
  • Money
  • Nissan
  • php
  • php4
  • php5
  • Querys
  • Query Times
  • shaved
  • Static
  • theme
  • the_content()
  • the_excerpt
  • truncate
  • weber
  • website
  • wordpress
  • worldvillage
  • world village
  • wp_insert_post

Tag: wp_insert_post

The Power of WordPress (WorldVillage)

A large group of people have managed to find WorldVillage. But few of these visitors will ever know that WorldVillage was built  on a WordPress foundation. You read that correctly, 17k posts (articles) and 1100 authors, as of March 2010. All on a WordPress based website.

“WorldVillage.com is a global community where you can share your interests and knowledge with others, learn about a diverse range of topics, and make some money along the way. “Villages” can be written on the subject of your choice, and are powerful platforms for you to gain exposure for your message and your name. At the same time, you can read and comment on other villagers’ writings and earn part of the ad revenue that your village generates.”

WordPress was used because of how much Google seems to love it. A few weeks after making the switch to WordPress and the site was up to a pr6 with several 1000 hits a day. Clearly, the meta information was not left to WordPress. There have defiantly been some modifications to the way meta data works, but that information must stay a secret.

Database Issues:
Wordpress wasn’t meant to handle any where near that many post, users or that much traffic. It was Immediately apparent that the database had to be optimized. Index were added along with a few secrets modifications. This helped with query times but there were still issues with the amount of querys.

I doubt I will ever be done trying to remove querys. One thing I found that helped was to pull the single posts out of the loop. That’s correct. I did away with the loop. Instead I created one query that pulled all the variables I need. I could then use these variables in the side bar and footer, thus removing any need to loop and run multiple query’s and or functions.

Build Process:
As for the build process, I was able to build a new author back-end that allows users to publish a post (article), without ever logging into the traditional wp-admin. One could remove the World Village theme and the site would go back to being a traditional WordPress blog, but why would one ever do that. I locked authors out of wp-admin and created a new series of pages that requires the user to be logged in. These page replace the traditional new post, with start building and add content pages. The power has been limited to help keep the newbs from messing anything up.

As for the process of adding post to the database is it still very much WordPress. I was very impressed by the functionality WordPress planned for. Simple functions such as <?php wp_update_post( $post ); ?> made the build much simpler then I expected. I simply needed to build an array and then pass in the new information.


// Create post object
$the_post = array();
$the_post['post_title'] = ucwords($_POST['title']);
$the_post['post_author'] = $author_id;
$the_post['post_name'] = sanitize_title($_POST['url']);
$the_post['post_category'] = array($_POST['category'], $_POST['subCat'] );
$the_post['tags_input'] = $keywords;


// Insert the post into the database
$post_id = wp_insert_post( $the_post );

A simple html form was used to capture the variable, then pass them to the handler. Rather simple when you think about the scope of this Content Management System.

Login Form:
Another thing that I wondered about before starting the project was how to build a custom log-in form. Once again I was rather surprised as to how simple this was.


<form name="loginform" id="loginform" action="/" method="post">
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" /


Username <input type="text" name="log" value="" size="20" tabindex="10" /> &nbsp;
Password <input type="password" name="pwd"  value="" size="20" tabindex="20" />


<input type="image" src="<?php bloginfo('template_url'); ?>/images/btn-signin.jpg"
onmouseover="this.src='<?php bloginfo('template_url'); ?>/images/btn-signin.jpg'"
onmouseout="this.src='<?php bloginfo('template_url'); ?>/images/btn-signin.jpg'" border="0" />


</form>

You simply need to know the name of the form fields and where to pass the data. I found this information very easy to get, by simple viewing the source code of a theme already containing a log-in form. I recommend adding a few security features, but any good programmer should be able to handle that.

Custom:
A few of the features such as the reporting system are completely custom but I am certain someone has made a plugin that will do something similar. I was able to use a plugin for the rating system but had to build a custom query and custom pagination for displaying the whats hot sections.

It is very nice to be able to turn a site over to a none programmer for day to day maintenance and moderation. Because the site is still WordPress, it was very simple to create a few administrators that handle the moderation.

Overall, I am very happy with the result and the functionality of WordPress, you can expect to see more custom WordPress site built by me.

Posted on March 27, 2010July 5, 2017Categories ProgrammingTags Authors, cms, content managment system, Database Issues, Global Community, Google, Meta Data, Money, Query Times, Querys, wordpress, world village, worldvillage, wp_insert_post22 Comments on The Power of WordPress (WorldVillage)
Proudly powered by WordPress