Archive for category WordPress

To disable comments for new posts

WordPress Admin Site > Settings > Discussion

To disable comments for previous posts and pages.

UPDATE wp_posts SET comment_status = 'closed' WHERE post_status = 'publish' AND post_type = 'post';# Affected rows: 1
UPDATE wp_posts SET comment_status = 'closed' WHERE post_status = 'publish' AND post_type = 'page';# Affected rows: 6

No Comments

List Posts in Certain Category on Homepage

<?php query_posts('cat=1&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php the_excerpt() ?>
  </li>
<?php endwhile; endif; ?>

No Comments

Using qtranslate for WordPress

http://shailan.com/3283/displaying-content-based-on-current-language-using-qtranslate/

No Comments

Steps to Deploy WordPress From Localhost To Your Web Server

  1. Export your DB from the localhost using phpMyAdmin as a .zip
  2. Extract the zip locally somewhere for editing
  3. Open the .sql file in jEdit (or equivalent UTF-8 capable editor) and do a string search for localhost
  4. Find the string you need to replace, usually http://localhost/your-site depending on how you’ve setup your local server.
  5. Do a global string replace using the replacement string you found and replace it with your new domain, something like http://your-domain.com
  6. Save in UTF-8 format. You might want to save as a new file just in case you need to revert.
  7. Using phpMyAdmin on your destination web server create a database and import the new .sql file. With some cPanel hosts like Bluehost it’s easier to create using cPanel’s tools then edit in phpMyAdmin for importing the file. If all is okay you should now have your database setup.
  8. Using FileZilla (or equivalent FTP program) upload your website’s files to the web server.
  9. While the upload is happening, it’s time to create the wp-config.php file for your production instance, make a copy of the existing wp-config.php file in your WP root directory.
  10. Open and change the database value to the name of your web server’s database for your site. Also, change the username and password for the database as required.
  11. Save this as wp-config.production.php and upload to your web server.
  12. Once all uploading is complete, using FileZilla rename the existing wp-config.php file on your web server to wp-config.development.php and also rename wp-config.production.php to wp-config.php. Your new config file is now in effect.
  13. Before you get all happy and try to visit your website you need to login to the WordPress admin and navigate to the Permalink settings. Once there just click the save button (don’t change anything, just re-save it). This resets the permalinks to your new URLs so the links to pages and posts will work throughout your site.

 

http://www.codemyownroad.com/13-steps-to-deploy-wordpress-from-your-localhost-to-a-live-web-server/

No Comments

  1. Make sure that jQuery library loads before the other (non jQuery) libraries.
  2. Insert the jQuery.noConflict(); after the main jQuery library is loaded, but before the other (non jQuery) libraries. In my case, when I viewed the source code of my WP pages, the jQuery.noConflict() was already loaded, so I didn’t have to do it manually. But, the mootools libraries of the FCG plugin were loaded before the jQuery.noConflict(); and we need to move it below. In order to achieve that:
    • I placed the following function, in the functions.php of my theme, to remove the FCG JS libraries from loading the way they were originally programmed:
      function remove_featured_gallery_scripts() {
             remove_action('wp_head', 'gallery_styles');
      }
      add_action('init','remove_featured_gallery_scripts', 1);
    • Then I added this function to load the FCG JS scripts last in general script loading order:
      function addscripts_featured_gallery() {
      	if(!function_exists(gallery_styles)) return;
      	gallery_styles();
      }
      add_action('wp_head', 'addscripts_featured_gallery', 12);
    • Make sure that after inserting those function you clear your browser’s cache and refresh you page.
    • Again, the order of our JS libraries should be the following:
      1. jQuery.
      2. jQuery.noConflict(); function.
      3. All other JS scripts and libraries including non-jQuery ones.

 

Source: http://www.ibsteam.net/blog/web-development/making-featured-content-gallery-work-jquery-jquery-powered-plugins

No Comments

WordPress Template Hierarchy

No Comments

WordPress

in theme’s functions.php

add the following php code

add_theme_support(post-thumbnails’);

No Comments

Making WordPress as Web Site

1. Make a tailor made template

Template: http://codex.wordpress.org/Stepping_Into_Templates

Following is the code for index.php or page.php, which is the empty theme for every page…


<!--?php get_header(); ?--></pre>
<div id="head_content"></div>
<pre>
	<!--?php while ( have_posts() ) : the_post() ?-->
	<!--?php the_content(); ?-->
	<!--?php endwhile; ?-->

<!--?php get_footer(); ?-->

WordPress looks for several Page template files in your active WordPress Theme based upon the Template Hierarchy. The first one it finds will be used to display any given Page. WordPress will look for files in the following order:

  1. The Page’s selected “Page Template”
  2. page.php
  3. index.php

The WordPress Template Hierarchy also recognized specific Pages or posts automatically without the need to assign them to a specific Page template file. If the Page with ID or slug in the template file name is automatically generated by the user, the appropriate Page template file is used.

  • page-{id}.php
  • page-{slug}.php

If the Page ID number is 42, the page-42.php template file is automatically used. If the Page slug is “About,” the page-about.php template file is used.

2. Using Permalink: http://codex.wordpress.org/Using_Permalinks
Need to enable apache mod_rewrite !!

No Comments