How can I echo out the user id in user meta?

I need to generate a unique ID number for each new member. I was going to use WP_query, but am not getting anything but an array. Answer If you want to display the info on the current user logged in you can use get_currentuserinfo. [Codex] Example from Codex <?php global $current_user; get_currentuserinfo(); echo ‘Username: ‘ … Read more

Query page: preserve page formating

dose anyone know how to get this query (or a different query) to preserve the page formatting? Thanks <?php $my_postid = 663;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; ?> EDIT I did not find a way to alter … Read more

Pagination on custom post type not working

I’m having a hard time getting pagination to work with my custom post type query. The standard “previous_posts_link()” and “next_posts_link();” aren’t working. And through a bit of testing, I’ve noticed neither “get_query_var(‘page’)” or “get_query_var(‘paged’)” are working. Also, adding “/page/2/”, “/2/”, or “/?page=2” isn’t finding a page. Any suggestions? if ( get_query_var(‘paged’) ) { $paged = … Read more

Incorrect posts displayed on category page

I’m using this loop to show my 5 latest posts but even if I’m selecting a category it still shows the 5 latest posts from all category. query_posts(‘showposts=5’); <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h1> <h4>Posted on <?php the_time(‘F jS, … Read more

query_vars category_name only display one catgory out of multiple categories

I am working on a plugin which alter the query arguments! Plugin uses $wp_query->query_vars[‘category_name’] to get the category slugs. Everything works when I am fetching posts from one category. But when passing comma separated slugs $wp_query->query_vars[‘category_name’] display only one first category. This is the loop $args = array ( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, … Read more

Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for WordPress Development Stack Exchange. Closed 2 years ago. Improve this question I am working with a company that provides online content in the form of semesters you pay to access. The semester … Read more

Get posts by meta value except one post [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago. Improve this question I have a meta_key with name director in my posts and i tried to show … Read more

How can I filter a query by post id?

In my wp_postmeta table, I have the following values: I’m trying query the posts whose ID lie in the meta_value column associated to a given post (the current post being viewed). For example, lets suppose I’m viewing post 94. As illustrated above I would like to retrieve the posts 108,78,90 associated with 94 and display … Read more

custom sort posts in archive/taxanomy page

I want to override the default sort order of posts in archive and taxonomy pages. what hooks should I implement? Answer Put something along these lines in your functions.php: add_filter( ‘pre_get_posts’, ‘custom_get_posts’ ); function custom_get_posts( $query ) { if( is_category() || is_archive() ) { $query->query_vars[‘orderby’] = ‘name’; $query->query_vars[‘order’] = ‘ASC’; } return $query; } reference … Read more