Easily get posts with a specific custom field/value on your WordPress blog
<?php query_posts('meta_key=review_type&meta_value=movie'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php query_posts('meta_key=review_type&meta_value=movie'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
//somewhere in the loop
$yourvariable = $post->post_content;
//do something
endwhile; endif; ?>
if (!(empty($_GET['section'])) || !(empty($_GET['article']))) {
global $wpdb, $post, $paged, $max_num_pages, $current_date;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = intval(get_query_var('posts_per_page'));
$offset = ($paged - 1) * $post_per_page;
$val = $_GET['s'];
$cat = $_GET['category'];
$tag = $_GET['tag'];
$querystr = "
SELECT DISTINCT $wpdb->posts.*
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta wpostmeta ON ($wpdb->posts.ID = wpostmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE
$wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_status='publish'";
//Tags and categories were like dropdowns so each time either "0" for no select or tag_id or //category_id or both were sent via GET as url params
if($tag > 0 && $cat > 0)
{
$querystr = $querystr . " AND ($wpdb->posts.post_title like '%$val%' AND ($wpdb->term_taxonomy.taxonomy = 'post_tag'
AND $wpdb->term_taxonomy.term_id IN($tag))) OR ($wpdb->posts.post_title like '%$val%' AND ($wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN($cat)))";
}
elseif ($tag > 0) {
$querystr = $querystr ." AND $wpdb->posts.post_title like '%$val%' AND ($wpdb->term_taxonomy.taxonomy = 'post_tag'
AND $wpdb->term_taxonomy.term_id IN($tag))";
}
elseif ($cat > 0) {
$querystr = $querystr . " AND $wpdb->posts.post_title like '%$val%' AND ($wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN($cat))";
}
$pageposts = $wpdb->get_results($querystr, OBJECT);
$querystr = $querystr . " LIMIT " . $offset . ", " . $post_per_page . "; ";
$sql_posts_total = $wpdb->get_var("SELECT FOUND_ROWS();");
$max_num_pages = ceil($sql_posts_total / $post_per_page);
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav id="<?php echo $nav_id; ?>">
<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'old')); ?></div>
<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'next')); ?></div>
</nav>
<?php endif; ?>
add_filter('posts_where','wpse_posts_where', 10, 2 );
function wpse_posts_where( $where, &$wp_query )
{
global $wpdb;
if ( $wpse_title = $wp_query->get( 'wpse_title' ) ) {
$where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( like_escape( $wpse_title ) ) . '%\'';
}
return $where;
}
<?php if(!(empty($_GET['category'])) || !(empty($_GET['tag'])))
{
$val=$_GET['s'];
$cat=$_GET['category'];
$tag=$_GET['tag'];
global $query_string;
$qstr= $query_string."wpse_title=$val";
$args['wpse_title']=$val;
if($cat>0)
{
$args['category__and']=$cat;
$qstr=$qstr."&cat=$cat";
}
if ($tag>0)
{
$args['tag__in'] = $tag;
$qstr=$qstr."&tag=$tag";
}
query_posts($args);
query_posts($qstr);
?>
now what does this mean
When submitting a form, you're trying to say
your browser to send via the HTTP protocol a message on the network
properly enveloped in a TCP/IP protocol message structure. When sending
data, you can use POST or GET modes to send data using HTTP protocol.
POST tells your browser to build an HTTP message and put all content in
the header of the message ( a very useful way of doing things, more safe
and also flexible). GET has some constraints about data representation
and length.$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'https://www.myapp.com/post_login_page'
);
$loginUrl = $facebook->getLoginUrl($params);
function enabletext(ele)
{
if(ele.checked==true)
{
var myid=ele.id;
jQuery(eval("'#" + myid + "'")).parent().siblings("#qtyid").show();
}
}