The tag has no usage guidance.

learn more… | top users | synonyms

-2
votes
1answer
28 views

Wrap every 2 divs in row - for each loop [closed]

For some reason, having a bit of a nightmare wrapping every 2 divs in a row in this for each loop.... Could anyone shed any light on it at all? <?php $terms = ...
0
votes
1answer
38 views

Check for image with same filename but different extension

I'm using the following code to show images in an ACF Gallery field <?php $images = get_field('gallery'); if( $images ): ?> <?php foreach( $images as $image ): ?> <figure class="...
0
votes
1answer
25 views

Trying To Get Child Categories To Show, Issue With foreach Loop

I made 6 sub-categories, all children of my "Resources" category, and I'm trying get them to display on a page, but at the moment it's only displaying the first category (leading me to believe my ...
0
votes
1answer
32 views

Getting a variable inside foreach from PHP to JS after localization

I believe I have properly enqueue'ed and localized my script - I've got $q showing up in the DOM. Now I'm sure I'm missing the simple last step to accessing a variable in the JS function. Here's my ...
0
votes
0answers
14 views

Display posts in a custom taxonomy, grouped by a different taxonomy

The setup: I have a custom post type called products. I have a custom taxonomy called styles with terms modern, classic, rustic. I have another taxonomy called seasons with terms fall, winter, ...
0
votes
0answers
31 views

How to query post from sub-categories on category archive and display posts?

On a custom taxonomy archive from the taxonomy called 'books' (taxonomy-books.php) I want to list all subcategories that are assigned to the parent category. And then for each subcategory I want to ...
1
vote
3answers
33 views

How to fetch an array in $wpdb?

I have a snippet that will select a data from database table. But I encounter an error: Warning: Invalid argument supplied for foreach() I encounter a new error: Notice: Trying to get property of non-...
0
votes
1answer
34 views

Foreach inside foreach

I got two taxonomies: "Colours" and "Recommended Colour" both have the same terms (same colours). I want to display a list of all terms of the taxonomy "Colours" and mark one colour as recommended. ...
0
votes
0answers
25 views

Display most popular posts

I have already found a way to display recent posts: <?php $args = array( 'post_status' => 'publish', 'numberposts' => '60', ...
1
vote
1answer
32 views

Undefined offset: 0

Here is my PHP function function getUserIDandPush($ul){ global $table_prefix; // Prefix for Database table global $user_login; global $wpdb; // Wordpress WPDB database method $dt = $...
0
votes
1answer
22 views

Get terms parent ID for conditional IF statement

I have the following working code to echo the name of the term (taxonomy called prodcats) that a series of posts are in. This is in the taxonomy archive template taxonomy-prodcats.php $terms = ...
0
votes
1answer
29 views

Foreach implode issue

I have this piece of code that gets the values of meta boxes in WordPress. $guiones = rwmb_meta( 'mb_guionistas', array( 'multiple' => true) ); $pieces = array(); foreach ($guiones as $item) { ...
0
votes
1answer
26 views

Remove Featured Images from Posts Older Than a Certain Date

I run a network of sites, with hundreds of editors, and lately we've had image copyright trolls coming after us. Most of these images are a year old or older, so we're looking to remove all images ...
1
vote
1answer
26 views

List terms from Custom Taxonomy

I have registered a custom post type "Projects" and also registered a custom taxonomy for that Post Type called "Project Categories". On my home page I have a div in which I would like to list all ...
0
votes
0answers
8 views

Book-like index on a page with foreach custom field and array merge

I'm trying to make a page with a Table of Contents in which my 'lyric' posts need to be ordered by three different custom fields. Basically each song could either be Original or about a Game, and in ...
0
votes
1answer
69 views

ACF loops false value with repeater and checkbox

I have an ACF repeater field setup on a page and within the subfields I have a True/False checkbox. So far, if the box is checked, it will show the fields. If not then it will not. However, the one ...
1
vote
1answer
34 views

Struggling with array and foreach loop

I have a function that outputs an array with 2 objects(?): Array ( [de] => 166 [it] => 167 ) Where [xx] is de language code and the number is the pageID. I'm having a meltdown in my brain as I ...
1
vote
1answer
24 views

Get post thumbnail from subpages with a foreach loop

I have created a page that loads content from it's subpages. The subpages contain post_thubnails. I use a foreach-loop to get the content of all pages. I just can't get the images loaded. <?php $...
0
votes
1answer
23 views

Why loop renders only last metabox from array? [closed]

The auestion is, why my foreach loop renders metabox only with information from last array? The code of class: class CusomMetaBox { /** * Hook into the appropriate actions when the class is ...
1
vote
1answer
47 views

Show only one category

I have this code to show cathegory like image: <?php foreach((get_the_category()) as $cat) { $catname =$cat->category_nicename; echo "<a href=\"/category/"; echo $catname; ...
1
vote
0answers
30 views

Category lists page foreach Paging

I use the following code shows the classification of the article with a list of all the category list on the page template, but such a page will be displayed all categories. I hope one page displays ...
0
votes
1answer
186 views

Invalid argument supplied for foreach() in search.php

I'm using this code on a search.php template to display search results, posts are formatted differently using a template part depending on the post term. This method works great on the index.php but I'...
1
vote
1answer
23 views

I need to get an array from the wordpress database

I need to convert this code //This creates an array from the database and allows us to use it later in the jquery //CREATE SQL STATEMENT $sql_locations = "SELECT * FROM tbllocations"; //EXECUTE SQL ...
0
votes
1answer
163 views

Can't get post thumbnail to display in foreach loop

I've been trying to get the post thumbnail to display in the foreach loop for a few hours now and I can't figure out how to make it work, any help would be greatly appreciated! <div id="...
0
votes
0answers
50 views

Display custom post type with is taxonomy in homepage

I've a custom post type called "books". Inside there're many book that belongs to a custom category (made with taxonomy) selected by user. All of these books, made a carousel for each taxonomy in ...
0
votes
1answer
91 views

Custom Post save causes 500 error

Been having issues with getting a 500 error. Sometimes a change is saved, usually not. I've output the $key/$values to verify it's reaching the function and foreach. The output is the first key/...
0
votes
0answers
36 views

How to display custom taxonomy grandest children in three columns, with first child as column heading?

I have a taxonomy structure thats 4 levels deep, with the name 'services_tax': Parent - Child - - Grandchild - - Grandchild - - - GrandGrandchild I am trying to get the terms selected on a custom ...
0
votes
0answers
21 views

Is it possible to loop bbp_register_view?

I added a taxonomy (location) to bbPress topics. I tried to register views for all terms, but it doesn't work. How to register for all terms? function taxonomy_custom_views() { $args = array( '...
0
votes
2answers
49 views

How do I turn these values from MYSQL into an array

I am working on a custom query to show a few posts. I am able to output all the post ID's. I am trying to turn these ID's into an array so I can use 'post__in' => $myarray in my query. How can ...
0
votes
1answer
20 views

Stop the execution of foreach loop which extract data from array?

In detail the condition is There are multiple new users to whom admin want to send welcome message but only once for each member. I have done sending message but if the member refresh his email page ...
0
votes
0answers
24 views

$wpdb->get_var not matching after first loop through foreach

I'm trying to match my array with a entries in a table and retrieving the ID of the entry. So I have the following array called $features. Array ( [0] => Body Side Moldings: Body-...
0
votes
0answers
37 views

Wordpress: Trying to echo taxonomy slugs of individual downloads, but limit them to the $atts[category] selected from shortcode from post

Note: I'm a reasonable newcomer to .PHP, starting with this project. I understand the concept of it, but I'm not yet skilled enough to figure out what functions I need to use for something a bit ...
0
votes
2answers
237 views

Most elegant way to enqueue scripts in function.php with foreach loop

I wonder is there a way of running wp_register_script and enqueue with the help of foreach loop to manage label and dir? For example, function wbs_app_components(){ $scripts_list=array( ...
1
vote
3answers
512 views

Limit number of pages in pagination

I have more then 500 posts and I want to limit only 100 posts with pagination. So, 10 pages with 10 posts in each. Here is my code. $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $...
1
vote
2answers
81 views

WP Query. Is there a maximum size?

I develop a plugin that searches for a duplicates of WooCommerce products in a very specific way. It works great in our test environment, but on the client's original setup it does not execute. It ...
0
votes
1answer
419 views

How to iterate within Magic Fields Group foreach loop?

Okay so I'm using Magic Fields 2 on an old WordPress project (rather than ACF unfortunately) and I've got some confusion happening while I'm writing PHP. Basically I'm on a page template that calls ...
0
votes
2answers
40 views

Output column number according to active sidebars

$sidebars = array( is_active_sidebar( 'footer-4' ), is_active_sidebar( 'footer-3' ), is_active_sidebar( 'footer-2' ), is_active_sidebar( 'footer-1' ), ...
0
votes
1answer
42 views

Foreach only outputs if id is 0

I'm developing a plugin. On the activation hook i do this: /* Create category */ global $wpdb; $rpdb_category = $wpdb->prefix . "rp_category"; if($wpdb->get_var("show tables like '$...
0
votes
2answers
344 views

Stop Duplicating Terms in a Foreach Loop

I have a foreach loop that prints out custom posts which uses a custom taxonomy. The user can then add whatever term/s they like to each post. This then prints out a list of terms on the custom ...
0
votes
1answer
437 views

Get Gravity Forms field values and count how many? [closed]

I don't know how to explain this the best way. But, I am using a form in Gravity Forms for rating something 0 - 10. In the code below, I can get the results. However, I need to see how many ratings ...
0
votes
2answers
47 views

get_post orderby not working in plugin

Please take a look at the loops below, I'm having issues trying to order the attachment by title, name, and modified. <?php foreach ($instance['data'] as $id) : ...
0
votes
2answers
328 views

Using ACF custom field for custom post type to order categories

I'm trying to use this answer to order categories based on their Advanced Custom Fields custom field: track_order. I'm able to get the UL to print fine and show the custom field numbers but I'm ...
0
votes
2answers
365 views

Get term name without a foreach loop

I currently have this: <?php $terms = wp_get_post_terms( $post->ID, 'artist-genre'); foreach($terms as $term) : ?> <li> <?php echo $term->name; ?> </li> &...
0
votes
1answer
319 views

List users by meta_key and meta_value

The following function will display a list of users based on their meta data: <?php function get_users_by_meta_data( $meta_key, $meta_value ) { $user_query = new WP_User_Query( array( ...
0
votes
1answer
31 views

How can I modify this code to iterate over an array of categories?

I'm setting up a query for a series of 12 classes that will last a week each. There will be a morning session and an evening session. I'll have two different loops in the template to break those apart....
0
votes
1answer
259 views

Foundation modal in wordpress php loop

I'm using Foundation V4 framework within a child theme for a website. I currently have the wordpress post loop outputting all the content as per normal, for images I plan to do something a little ...
0
votes
0answers
267 views

Display Users by usermeta using foreach loop with multiple relationships

I'm getting a real headache trying to sort this one out. Here's my problem: I'm working on a feature for a site that requires Users to be displayed according to their association with a common ...
1
vote
2answers
1k views

Get direct children of custom taxonomy

I've googled extensively and tried my best, but I just can't get the first level children of the custom taxonomy in the code below to work! It only displays the parent level. What I am trying to ...
0
votes
1answer
461 views

Different column width in 2 rows with bootstrap and custom post types-different classes needed

I'm using a custom post type on my WP website and also using bootstrap. I want to list 5 custom post type entries on my home page, and I want the first 3 to have class col-md-4 in one row and in the ...
0
votes
1answer
223 views

ACF field not appearing correctly in loop

There is a loop in my theme that displays posts with the following information: a title, some text, and a price. I have added a custom field to this post type using ACF. The field ID is tour_length. I ...