Most liked page not displaying posts

Thats code just querying the posts by sorting it by meta value, but you have no loop for the posts to display. Add the loop after the query for something like this: echo ‘<ul>’; if ( have_posts() ) : while ( have_posts() ) : the_post(); echo ‘<li>’; the_title(); echo ‘</li>’; endwhile; endif; echo ‘</ul>’;

mysql query from wordpress page using custom table

I think if you add a couple of periods before and after the php variable in your query, remove the use of mysql_fetch_array, and use get_row(), it should work better. Here’s how I would get a park from your custom table: <?php $page_title = wp_title(”); $park = $wpdb->get_row(“SELECT * FROM $wpdb->park_data WHERE park_name=””.$page_title.”””); if($park) { … Read more

How do I pass a post ID to the page URL?

First of all. The question is a little misleading. What you actually want is “post id(s) for current user”. Here we go: // Global variable for current user ID // More information: http://codex.wordpress.org/Function_Reference/get_currentuserinfo $user_ID; // You need to create a new WP query object // More info: http://codex.wordpress.org/Class_Reference/WP_Query $my_query = new WP_Query( array( ‘post_type’ => … Read more

Logged in user ID as post ID

You can get information on the currently logged in user using the get_currentuserinfo() function. For example: <?php global $current_user; get_currentuserinfo(); $username = $current_user->user_login; $user_id = $current_user->ID; ?> You can then use $username or $user_id in your custom loop. <?php // assign the variable as current category $category = $user_id; // concatenate the query $args=”cat=” . … Read more

Date calculations from 2 custom fields

I don’t know how much this will help, but when I’ve done date/time comparisons, I’ve always had to convert them to UNIX timestamps first (converts the date/time to a numeral, which you can compare as less than/greater than/equal to the next number), and then after the difference is sorted, convert it back with date(). A … Read more

I would like to have different styles for my posts based on the content of each post

Depending on which ‘types’ you need, you might be looking for the Post Format functionality. It allows you to set posts as standard, quotes, galleries, etc (sort of like Tumblr). To activate it, simply toss this into your theme (probably functions.php): add_theme_support( ‘post-formats’, array( ‘aside’, ‘gallery’, ‘quote’ ) ); Then, in your templates, you’ve got … Read more

custom fields wordpress

The update_user_meta and get_user_meta functions are what you want, without having to fool around with any database connections or SQL. All it takes is one include statement in your theme, and a bit of PHP magic to call the meta functions. Check out my code, which accomplished what you are trying to do, on Github … Read more

How to add a php custom page to WordPress

Please refer to the Page Templates section of the Static Pages Codex entry. Essentially, you create a custom page template, named something like template-foobar.php, which will live in your Theme’s root directory, or in a one-deep sub-directory. Inside this template file, add the following: <?php /** * Template Name: Foobar */ get_header(); // YOUR CUSTOM … Read more