Tag Info

New answers tagged

0

From what I understand you have a loop that displays up to 500 pages. If the page parent = 18219 than you want to query the tags for that page. As far as I know, by default WP does not allow you to tag Pages, only Posts. But let's pretend you have a plugin that allows you to do that... Inside your loop you can check to see if the page has a parent equal to ...


0

Your basic query logic looks fine assuming you want an AND relationship between the first, middle, and last names but query_posts is never, ever, ever the right way to do anything. Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is ...


0

You shouldn't use query_posts functions. You should create instance of WP_Query class In your theme folder create a new file called category-slug.php. You can copy the category.php file or archive.php file to create category-slug.php file. Then in the new category-slug.php file before the while loop you can write your query. $query = new WP_Query( ...


0

You can use either GET or POST requests to achieve that functionality without using any AJAX (which, in fact, does the same but uses JS to process requests). You need to add ?name_of_var=value after trailing slash on labels that link to different queries. Basically, your 'Coca-Cola' link has to look this way: site.com/products/?brand=cocacola After that, ...


0

You need to use the post__in parameter and pass an array of the page ID's to the parameter. You can do the following: (Note: you need to use the array syntax in WP_Query if you pass post__in as an argument) <?php $the_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 1, 2, 3 ) ) ); ?> Just change 1, 2, and 3 to the ...


2

query_posts - You should never ever use query_posts. Apart from what @Rarst has said, the really big issue with query_posts is, it breaks the main query object ( stored in $wp_query ). A lot of plugins and custom code relies on the main query object, so breaking the main query object means that you are breaking the functionalities of plugins and custom code. ...


2

Your logic in your code is wrong. Read your code in plain English. If the current post is number 3, show my custom content, else, show the posts as normal. What you want is the following If the current post is number 3, show my custom content. Show all my posts as normal To achieve this, you need only wrap your custom content in your ...


0

Just wanted to share a link that helps explain comments contained in the answer: http://solislab.com/blog/5-tips-for-using-ajax-in-wordpress/ Here's tip 1 mentioned in one of the comments: USE WP_LOCALIZE_SCRIPT() TO DECLARE JAVASCRIPT GLOBAL VARIABLES Although wp_localize_script() is created for localization, it also has another great use. You can ...


3

Your problem is your custom query. Do not use variables that is used by default by Wordpress. $posts and $post is Wordpress reserved global variables. Change $post to a unique variable, something like $posts_query. When using get_posts and you need to setup postdata to make use of template tags, you have no choiche but to use $post as setup_postdata() ...



Top 50 recent answers are included