Get Posts that have featured Images


$args = array(
'post_type' => 'post',
'posts_per_page' => 7,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);

$query = new WP_Query($args);
while($query->have_posts()) {
$query->the_post();
if ( has_post_thumbnail() ) { // double checking
$out.= the_title();
$out.= get_the_post_thumbnail('thumbnail');
}
}

MySQL query logging

As of MySQL 5.1.12, you can rename the general query log file at runtime by disabling the log:

SET GLOBAL general_log = ‘OFF';

With the log disabled, rename the log file externally; for example, from the command line. Then enable the log again:

SET GLOBAL general_log = ‘ON';

This method works on any platform and does not require a server restart.

http://dev.mysql.com/doc/refman/5.1/en/query-log.html

Network windows 7 and OS X

Goto Start Menu
Search for: security
Click on Local Security Policy
Goto Local Policies> Security Options
Double Click on Network security: LAN Manager Authentication

Look in Network for the OS X computer you have enabled sharing on !
Change level to: Send LM # LTLM Responses

Then, scroll down to Network security: Minimum session security for NTLM SSP
De-select Require 128-bit encryption
Hit OK

OS X apache permissions

Setting up a web server on OS X other than the built in one and serving sites from the Document directory always causes permissions headaches this stackoverflow response helped nut it out ( http://stackoverflow.com/questions/2001881/correct-owner-group-permissions-for-apache-2-site-files-folders-under-mac-os-x )

In Summary

This is the most restrictive and safest way I’ve found, as explained here for hypothetical~/my/web/root/ directory for your web content:

  • For each parent directory leading to your web root (e.g. ~/my~/my/web~/my/web/root):
    • chmod go-rwx DIR (nobody other than owner can access content)
    • chmod go+x DIR (to allow “users” including _www to “enter” the dir)
  • sudo chgrp -R _www ~/my/web/root (all web content is now group _www)
  • chmod -R go-rwx ~/my/web/root (nobody other than owner can access web content)
  • chmod -R g+rx ~/my/web/root (all web content is now readable/executable/enterable by _www)

Filter WordPress menu

// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items) {
// gets passed a string of <li>’s
$homelink = ‘<li><a href=”‘ . home_url( ‘/’ ) . ‘”>’ . __(‘Home’) . ‘</a></li>';
$items = $homelink . $items;
return $items;
}

add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ );

Another Example

function new_nav_menu_items($items) {
$cat_menu_list = wp_list_categories( ‘echo=0&title_li=&child_of=124′ );
$items = $items . $cat_menu_list;
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ );

WordPress Super Loop

// if everything is in place and ready, let’s start the loop

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

// to display ‘n’ number of posts, we need to execute the loop ‘n’ number of times
// so we define a numerical variable called ‘$count’ and set its value to zero
// with each iteration of the loop, the value of ‘$count’ will increase by one
// after the value of ‘$count’ reaches the specified number, the loop will stop
// *USER: change the ‘n’ to the number of posts that you would like to display

<?php static $count = 0;
if ($count == “n”) { break; }
else { ?>

// to exclude all posts from categories ‘x’, ‘y’, ‘z’ unless in single-post view
// create an ‘if’ statement for each of the three specified categories as follows:
// if the post is in category ‘x’ and this is not a single-post view, exit the loop
// if the post is in category ‘y’ and this is not a single-post view, exit the loop
// if the post is in category ‘z’ and this is not a single-post view, exit the loop
// if no conditions are met, continue the loop; otherwise restart loop with next post
// if none of these conditions are met, run the loop; otherwise restart at the next post
// *USER: change the ‘x’, ‘y’, ‘z’ to the numbers of the categories you want to exclude

<?php if ( in_category(‘x’) && !is_single() ) continue; ?>
<?php if ( in_category(‘y’) && !is_single() ) continue; ?>
<?php if ( in_category(‘z’) && !is_single() ) continue; ?>

// use this to display posts from category ‘x’ in single and archive views only
<?php if ( in_category(‘x’) && !is_single() && !is_archive() ) continue; ?>

// use this to display posts from category ‘x’ in single and category views only
<?php if ( in_category(‘x’) && !is_single() && !is_category() ) continue; ?>

// use this to display posts from category ‘x’ in single, category, and archive views only
<?php if ( in_category(‘x’) && !is_single() && !is_category() && !is_archive() ) continue; ?>

// now, if all conditions have been satisfied, the post is displayed
// for CSS styling and layout purposes, we wrap the post content in a div
// we then display the entire post content via the ‘the_content()’ function
// *USER: change to ‘<?php the_excerpt(); ?>’ to display post excerpts instead

<div>
<?php the_content(); ?>
</div>

// here, we continue with the limiting of the number of displayed posts
// each iteration of the loop increases the value of ‘$count’ by one
// the final two lines complete the loop and close the if statement

<?php $count++; } ?>
<?php endwhile; ?>
<?php endif; ?>

from http://perishablepress.com/press/2007/08/06/super-loop-exclude-specific-categories-and-display-any-number-of-posts/

Moving Virtuemart

When moving virtuemart from a build directory

Edit administrator\components\com_virtuemart\virtuemart.cfg.php
define( ‘URL’, str_replace(“/administrator/”,”/”,JURI::base()));
define( ‘SECUREURL’, str_replace(“/administrator/”,”/”,JURI::base()));