How can I comment comma-separated array values?

No, it’s definitely not okay to comment your code this way. It changes the string, and even though WordPress might strip the incorrect characters and yield the correct pages (it wouldn’t if your “comments” contained comma’s or numbers), it is incredibly unstable. Instead, if you do want to comment them, I would suggest storing them … Read more

pre_get_posts – editing query, tax_query

So there’s a few things wrong with the code: You’re not using the query object that’s passed to the pre_get_posts hook, so you’re not modifying the actual query. Field is set to id instead of term_id. If you’re using IN as the operator, pass an array to terms. You’re not sanitizing the value of $_POST[‘networks’]. … Read more

WP_User_Query and user posts

If you pass in the fields parameter to your user query you can easily get an array of ids to the pass in to your wp query : //WP User Query $author_query = new WP_User_Query( array ( ‘number’ => 3, ‘fields’ => ‘ID’ )); $author_results = $author_query->results; //WP Query $postArgs = array ( ‘author__in’=> $author_results, … Read more

Use title of post as argument for query

Yes! You meant to use get_the_title() which returns the title as a string. the_title instead outputs it to the browser. The same is true of many other functions in WordPress, e.g. the_post_thumbnail vs get_the_post_thumbnail or bloginfo vs get_bloginfo For future reference, a search on https://developer.wordpress.org will usually reveal related functions

Loop returns the current page’s permalink and guid instead of the post in the loop

I’m actually surprised that your code is working. There are several typos in it that should be throwing fatal errors. global $post; $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : ?> <?php $the_query->the_post(); $id = get_the_ID(); ?> … Read more

Display custom post type for specific user

try this: $args = array( ‘author’ => get_current_user_id(), ‘post_type’ => ‘YOUR_CUSTOMPOST_TYPE’, ); $author_posts = new WP_Query( $args ); if ($author_posts->have_posts()): while ($author_posts->have_posts()) : $author_posts->the_post(); //DISPLAY CONTENTS HERE endwhile; endif; wp_reset_postdata(); wp_reset_query(); replace YOUR_CUSTOMPOST_TYPE with your post type, what it does is finds posts of certain post type whose author is currently logged in user. Currently … Read more

PHP – Loop custom post type categories within jQuery Tabs

You can fire query only by ‘meta_key’=> ‘selsubcat’ without meta_value `and you will get all subcategories. Then you should loop outside you tab with some increment(maybe a name of category or numeric id) something like this: <?php foreach( $posts as $post ): setup_postdata( $post ); ?> <div id=”tabs-<?php the_ID(); ?>”> <table id=”table-<?php the_ID(); ?>” class=”display” … Read more