The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
76 views

Show message if statement is false - foreach

I got this PHP script from http://tutorialzine.com/2010/02/php-mysql-download-counter/ and integrate it to my wordpress successfully. It works but the "No Download File" message appears even the value ...
0
votes
1answer
505 views

Display post thumbnail in foreach loop

I am trying to display a thumbnail in a foreach loop. The thumbnail is a new image size I have added called "plant-thumb". I have all the desired elements displaying properly except for the thumbnail. ...
0
votes
1answer
91 views

Getting “Invalid argument supplied for foreach()” Warning

I am on the last step in a tutorial that I followed here , called "Using the data". I tried using// $album_repeatable = unserialize($post_meta_data['album_repeatable'][0]); echo '[ul ...
0
votes
1answer
390 views

Add number in increment of one to DIV ID

I'm using a shortcode to display a custom post type. The shortcode contains an attribute to display only posts of a specific category within the custom post type e.g. [faq category="travel"] For each ...
0
votes
1answer
90 views

How to remove certain words from url slug

Trying to create a SEO plugin, that will remove stop words from slugs. This is how to explode the $slug into a list, and explode the variable containing the stop words : add_filter ('sanitize ...
-1
votes
1answer
1k views

Eliminate duplicates in a foreach loop [closed]

I've created a filter for my search results that allows people to filter user searches based on their State from their profile. The problem I am having is that there are duplicate states showing in ...
1
vote
1answer
1k views

Custom widget using get_categories select menu dropdown

I have created a custom widget that is supposed to display a select menu with all the categories the blog has. I have used get_categories to compile the list. This works fine and all categories appear ...
0
votes
1answer
112 views

Paginating a list of all posts collected by category titles

I'd be really grateful if anyone has any ideas about what might be wrong with this code or, alternatively, could suggest an entirely different way of achieving the same aims. I have a site (staged, ...
0
votes
1answer
644 views

Pagination for multiple queries merging into one Loop

I have an events site where I want to display upcoming events that can be booked in ascending date order and then events that are closed for registration in descending order. I'm using get_posts for ...
0
votes
1answer
398 views

update_post_meta only updating on last loop of foreach

I'm building a way to upload multiple files for an announcement custom post type on the front end. My function here uploads any number of files succesfully so I can see them under "Media" in ...
1
vote
0answers
18 views

How to write an efficient metabox with repetitive fields [duplicate]

Possible Duplicate: Create more Meta Boxes as needed I’m having a hard time to write an efficient code for the below Metabox. Since I do not want to use any third-party class, I’m trying to ...
0
votes
1answer
556 views

How to get the next and previous image title from attachment or gallery?

I'm trying to build a slider exactly like this in wordpress. I have managed to make the slider work except the next/prev button. I need to get the next image title and the previous image title for the ...
0
votes
1answer
162 views

Insert new post for each user infinite loop error

I wrote this little function to automatically create a post for every user of the blog but it creates an infinite loop (I disabled it to stop it creating new posts). I'm not very skilled in php, I ...
0
votes
1answer
143 views

How to reduce three query to one in multiple output template?

I would like to publish 7 posts from the same category but embedded in different DIV or UL. How could I simplify this code? <?php $query01 = array( 'numberposts' => 1, 'offset'=> 0, ...
3
votes
2answers
796 views

Display data from a non wordpress database on a page template

I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin. $rows = ...
0
votes
1answer
288 views

foreach repeat html structure after every nth for attachment [closed]

I am trying to achieve result with below structure in foreach loop where after every two images it will repeat entire structure. I have some basic knowledge for something I can use eg. counter++; and ...
0
votes
2answers
468 views

Meta Box Plugin Cloned Fields - Multiple Foreach values

I have the following code that I can't get working. I have two cloneable fields that are being output as one entity (URL and thumbnail image). These are cloned fields using the Meta Box Plugin by ...
2
votes
2answers
922 views

Count total number of post in foreach loop

I used the the following script (only with get_permalink....) to display posts from a post type where the post author has an extra meta field on his user page: <?php // get users from user page ...
0
votes
2answers
69 views

Way of getting queried loop before the query with a filter hook?

Is there a way to get the results of a loop with a filter before the code for the loop is performed in the structure of your code? My markup is something like this: <body> <div> /* ...
0
votes
1answer
305 views

Compare current post Category in select menu

i have done this many times but not via a form so i am getting a weird issues when trying to assign a "selected" based on the current post term id... Maybe the use of get_the_category and then ...
0
votes
1answer
385 views

Why use foreach to get attachment_id if numberposts is equal to 1?

I needed to pass an image to a Pinterest plugin in posts without a Featured Image so I wrote a little function to get the id of the first picture in a post. This code is in the loop-single.php where ...
1
vote
1answer
252 views

Get posts inside Get terms problem

i have a get_terms which loads correctly. inside of it i have used get_posts. then using get posts i am trying to get each post tags (and count <= not currently inside this script) <?php ...
0
votes
1answer
451 views

Passing a variable from a FOREACH loop in a link

How would you pass a variable from a foreach loop, through a link? I have tabs that display correctly. The jQuery works. But when I call the variable $category down where the content sorts, $category ...
0
votes
1answer
404 views

Sets post_parent in custom post type posts automatically based on cpt->page name

I'm trying to write a function that will "pair" my custom post type with a page with the same name as the custom post type. The aim is that when a custom post type is saved, it checks if there's a ...
0
votes
2answers
93 views

How to randomise my menu items?

So I thought I could do it like this (also I want to only get 3) - $menu_items = wp_get_nav_menu_items(26); $menu_items = array_rand($menu_items, 3); foreach ( (array) $menu_items as $key => ...
0
votes
2answers
221 views

How to check all items in a loop have post thumbnail?

Currently I have the following loop: <?php $shows_sales = get_posts(array( 'post_type' => 'show_sale', 'post_status' => 'publish', 'posts_per_page' => 3, )); $done_image = ...
0
votes
1answer
276 views

Loop not displaying comments_popup_link

I cannot get the comments_popup_link to display with the posts retrieved by the foreach loop. Only the title and permalink are displayed. Any idea why the comment link is left out? <?php ...
4
votes
2answers
5k views

How to get permalink and title from post ID?

I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if ...
0
votes
1answer
294 views

Can't seem to get set_blog_id working, it just doesn't reset the blog ID

Trying to iterate through a list of the sites and I can't seem to get set_blog_id working. Here's the sample output: Array ( [0] => stdClass Object ( [blog_id] => 2 ) [1] => stdClass Object ( ...
-1
votes
2answers
251 views

Different Output for “Every Other” Foreach Statement?

I'm currently using the following code in order to get subcategories in a category page and getting the posts foreach subcategory. In the part where it echos "span-12" (line 14) i want it to echo ...
0
votes
2answers
202 views

Lists Top Authors by Most Recent Posts

I'm trying to display a table format of the top authors listed by the most recent posts. It should display the author, its avatar, the date, and the title of the post (with a link). I have it ...
1
vote
1answer
624 views

Loop through child images of a parent for a Nivo Slider

I want to use a Nivo slider to cycle through the children of a parent page one by one, how can I do that? I have the following piece of code that grabs ALL the children of a parent page and displays ...
-1
votes
1answer
546 views

Combine two foreach Arrays into one table row

right now I have two foreach arrays - one outputs the artist, the other a track title I would like to combine both so there is a row for each artist and corresponding track for example: Row 1 - ...
0
votes
2answers
329 views

Simple foreach loop help needed in wordpress “the loop”

I need a foreach loop inside "the loop" This is my current code (index.php) : <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div><a href="<?php the_permalink(); ...
2
votes
1answer
493 views

Advanced Custom Fields - Storing array value for further usage

This might might be more of a PHP question - but does deal with a WordPress plugin, Advanced Custom Fields I am using a global select option to store a specific Location (custom post type) as the ...
0
votes
1answer
997 views

Display metabox title for custom fields with values

I'm using multiple metabox panels in my write posts. IN my functions I'm registering multiple metaboxes: $prefix = 'dbt_'; $meta_boxes = array(); $meta_boxes[] = array( 'id' => ...
0
votes
1answer
401 views

Retrieve IDs from custom field, count and display results differently according to count

The function below is inside a single post loop. I have an array of IDs in a custom field. Such IDs represent related posts. I'm using Advanced Custom Fields (ACV) plugin and I manage the custom ...
0
votes
2answers
610 views

Code that displays images - images get shown multiple times

On My category.php page i've got a list of categories with the title and the description. Here's the code: <?php $cat_id = get_query_var('cat'); $catlist = ...
0
votes
2answers
454 views

Add class to last 3 posts in loop

I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it ...
1
vote
3answers
251 views

query in category.php repeats itself

I'm need some help on my query. I'm building up a category page where on top a post need to show where custom field key 'uitleg' has value 'ja'. Per category there is only one post with that value. ...
0
votes
3answers
535 views

Custom Database Table and foreach

I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement. Some guidance in this matter would be great. ...
0
votes
1answer
2k views

Count within foreach loop

How can I echo out the count of within a foreach loop? I want to change the class of the div below so it's menu-button-1, menu-button-2 etc etc: <?php $pages = get_children(array('orderby' ...
0
votes
1answer
422 views

Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH

I'm learning how to write a shortcode. I'm getting this error: Parse error: syntax error, unexpected T_FOREACH . I'm having problems with concatenating it properly. <?php /* Plugin Name: My ...
1
vote
2answers
477 views

Make Selected Mutiselect Items “selected”

I'm developing a theme settings panel for a new wordpress theme that have an option to exclude categories from being shown in the loop. I managed to get the main functionality to work, using a ...
1
vote
2answers
4k views

In a foreach loop, how do I target the last item in the loop?

I have the following code to do a foreach loop, I want to target the last item in the loop (e.g if it's looped over 3 events I want to target the 3rd event) to do something slightly different with the ...
1
vote
1answer
999 views

Limit get_pages to only show 5 items

How can I limit the get_pages to only show 5 items? I thought adding 'number' => 5 to the array would limit it to 5 but it doesn't show anything. Here's my code: <?php $pages = ...
0
votes
1answer
628 views

Wordpress: paginating array using a foreach

I currently grab an array of user data from a query. I then use a foreach to loop through them and apply styles and divs to output them to the page. This all works great but i would like to paginate ...
1
vote
2answers
2k views

mysql query two database tables, users and usermeta and sort by custom meta int value

I am trying to get an array of site users sorted by a custom meta value (an int). I can query the users just fine and get them back to use in a foreach. I currently have the query results come back ...
0
votes
2answers
1k views

WordPress MS wp-admin/includes/post.php error with shortcode generator

I'm having a serious issue with Wordpress 3.1 with Multi Site enabled and my themes custom shortcode generator. For some reason, I'm getting the following error whenever I create a new ...
2
votes
3answers
1k views

Using a loop to display terms associated with a post

I'm using a custom post type and custom taxonomies, and using the following to display the terms of the taxonomies on the post page: the_terms( $post->ID, 'taxname', 'beforetext', ', '); Is ...