Calling Custom Post Meta

you can use <?=$website_url?> in the portfolio template like <strong>URL: </strong><a href=”https://wordpress.stackexchange.com/questions/32957/<?=$website_url?>”><?=$website_url?></a> to make it like follow <?php /* Template Name: Portfolio */ ?> <?php get_header(); ?> <div id=”content”> <?php $loop = new WP_Query(array(‘post_type’ => ‘portfolio’, ‘posts_per_page’ => 10)); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $custom = get_post_custom($post->ID); $screenshot_url = $custom[“screenshot_url”][0]; … Read more

Unable to sort wp_query by date/time with multiple meta_key s

Just an idea: you could save your time values in an array and then sort it with PHP. Example: $keys = array(‘opening_time’, ‘film_time’, ‘artist_talk_time’); $times = array(); $custom_field_keys = get_post_custom_keys(); foreach ($custom_field_keys as $custom_field_key) { if (in_array($custom_field_key, $keys) { $custom_field_value = get_post_meta($post->ID, $custom_field_key, true); if ($custom_field_value >= $thedate && $custom_field_value <= $future) { $counttest++; $times[$custom_field_key] … Read more

wp_redirect to file:// location results in blank page/cannot be displayed page

The above code didn’t work because of browser security. I’ve decided to go with this code: <?php global $post; the_post(); $location = get_post_meta($post->ID, ‘sc_stace_resource_location’, true); $count = (int) get_post_meta($post->ID, ‘sc_stace_view_count’, true); $count++; update_post_meta($post->ID, ‘sc_stace_view_count’, $count); ?> <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <html> <head> <title><?php the_title(); ?></title> <meta http-equiv=”REFRESH” content=”1;url=<?php echo $location; ?>”> </HEAD> … Read more

and custom post_types to custom menu

Try adding the action after the function like this: function mt_add_pages() { // Add theme options page to the addmin menu add_menu_page(__(‘Competition’,’comp’), __(‘Competition’,’comp’), ‘manage_options’, ‘mt-top-level-handle’, ‘test_func’, ”, 5 ); add_submenu_page(‘mt-top-level-handle’, __(‘Answers’,’comp-answers’), __(‘Answers’,’comp-answers’), ‘manage_options’, ‘sub-page’, ‘test_func2’); } add_action( ‘admin_menu’, ‘mt_add_pages’ );

Custom post type permalink structure

function myrules(){ add_rewrite_rule(‘^yourcptslughere/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?p=$matches[1]&taxonomy=$matches[2]&name=$matches[3]’,’top’); } add_action(‘init’,’myrules’); Replace the ‘yourcptslughere‘ with what you wanted, and then add that to functions.php then flush your rewrite rules, and the final example you posted should work. I doubt it will be what the_permalink() returns however so you will have to construct the urls yourself, however they should be viewable at … Read more