The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
2answers
33 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( ...
0
votes
0answers
12 views

Taxonomy Term Variable within Foreach Loop

I have a foreach loop that cycles through all the terms of a specified taxonomy (product_cat in this case). I have the terms in a variable called $productTerm but I cannot get it work in one section ...
1
vote
3answers
68 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
votes
0answers
18 views

Why is my foreach loop preventing other subsequent loops working in php document?

I'm trying to create a section on my wordpress site for latest posts to be displayed with date title and an excerpt. I don't know what is causing this, but the loop I am using stops all subsequent ...
1
vote
2answers
34 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
117 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
25 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
25 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
0answers
40 views

Reorder results of select query by distance

What I'm trying to achieve is a store directory listing nearby stores, ordered by distance. I've managed to grab all the stores within the specified radius and display them, and also calculated the ...
0
votes
2answers
89 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
77 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
26 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
80 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
0answers
59 views

Check ACF fields in foreach custom taxonomy

I currently have a custom post type page set to pull in data that's attached to a custom taxonomy with ACF: <?php $terms = get_the_terms( $post->ID, 'artists' ); foreach($terms as $term) : ...
0
votes
2answers
85 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
78 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
23 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 ...
0
votes
1answer
93 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
88 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
333 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
0answers
18 views

How to add additional for each statement

I am using the function below to display the date of an event (using the Event Espresso plugin). I need to add next to the date, on the same line - the city and state of the event using this for each ...
0
votes
1answer
229 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
91 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 ...
0
votes
0answers
25 views

wordpress database error

I write code to extract peice from website with curl. this should be refresh page to get price. I want store data in the wordpress database with foreach. when I refreshing page but give this ...
0
votes
0answers
57 views

Send Custom Post Notification to Followers

I am trying to modify the function below (which works great for me ) to notify author followers that the author has published a new post, but I seem to be going round in circles. function ...
0
votes
1answer
90 views

How do I use foreach to get content from a custom-field in multiple posts?

so I am trying to use a foreach to pull content from a custom field in multiple posts, but it just wont work. I can get it to work for a simple textarea string but I am struggling getting it to work ...
0
votes
1answer
66 views

Stuck in the query loop

I created a two loop into my WordPress page. It should get the category name and should load all the child under the Category name. Like this ____ Cat1 ______ product 1 product 2 product 3 ____ ...
0
votes
1answer
1k views

Need to add class to first element in a foreach loop

I'm pulling all attachments for this particular post and displaying them in a carousel. Problem is I need to give the first item a class of active so bootstrap carousel will work. Here is my loop: ...
1
vote
1answer
121 views

Only showing the_date and the_excerpt for first entry in get_posts

this code below shows the titles and links for 5 posts in get_posts no problem but only displays the date and excerpt for first post... any help please? <?php $args = array( 'posts_per_page' ...
0
votes
1answer
62 views

get_the_content within foreach not the loop

I want to retrieve the content of posts within a foreach loop. $recent_posts = wp_get_recent_posts(); $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ...
0
votes
1answer
878 views

preg_replace() No ending delimiter '.' found [closed]

I get this error: Warning: preg_replace() [function.preg-replace]: No ending delimiter '.' found in but I can't figure out why Here is the code: foreach( $content as $item ) { ...
0
votes
0answers
73 views

$wpdb->get_results in not an array

Using get_result I receive an "Invalid argument supplied for foreach()" because is not an array. I tried with get_col but I don't know how to extract the data and I don't know the difference between ...
0
votes
0answers
33 views

Update options and then display it all in a foreach loop

I am really new in wordpress development but not new in coding, what i would like to do is to make my own countdown wp plugin. The problem as a beginner is that i dont understand how works the wp ...
0
votes
1answer
117 views

Strange switch_to_blog() issue

OK, so WordPress has been destroying me this afternoon and this particular issue I really can't figure out. We are building a multisite network and for our particular purpose need to loop through each ...
1
vote
2answers
232 views

how to save selection meta data in user profile on frontend

Hi can anyone help me to save the post title selected in this select box? I would like to let people select posts out of a dropdown select box and save the value to their profile. Help is very ...
0
votes
0answers
140 views

Foreach inside shortcode not working as planned

I have a loop inside a shortcode to display the list of posts for each category (schedule-day) in a custom post type (schedule). The first category lists the posts in said category just fine, but ...
0
votes
1answer
316 views

Exclude category from foreach loop

How can I exclude one category from this loop wher I list my custom type projects by year ? <?php foreach(posts_by_year() as $year => $posts) : ?> <h3><?php echo $year; ...
0
votes
1answer
290 views

Second foreach in the loop returns bool(false) though array is present

In my code below the data is extracted correctly for the first foreach, but doesn't return anything for 2nd foreach although selected one present inside the 2nd foreach. I still get the error ...
0
votes
3answers
1k views

Advanced Custom Fields - Relationship post foreach query

I've created a post type, called Package (for news packages), and want to be able to link to specific blog posts and display them on the single-package.php page. I'm using ACF relationship fields, and ...
0
votes
3answers
2k views

How to get post or page excerpt using post_excerpt

I am using the following foreach loop: $pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order',)); foreach ($pages as $page) { $apage = $page->post_name; ...
0
votes
1answer
210 views

foreach,having wp_query inside, breaks after showing one result

I am trying to make category tabs that show posts from selected category tab. I have tried it my way but m getting only one post for each category, whereas it should return all post in that category. ...
0
votes
0answers
11 views

foreach loop pagination for taxonomy blog category [duplicate]

I have a wordpress website running in which I have a blogs page where I display all the blogcategories using the following code <?php $taxonomy = 'blogcategory'; ...
0
votes
1answer
183 views

Custom post type archive organized by category

I'm trying to display a custom post type archive page which displays all the articles of a a custom post type in columns. The columns organize them in their assigned category. On the main page, I do ...
0
votes
1answer
158 views

foreach loop inside the loop creating duplicates in output

I have a foreach loop inside the loop that is getting info from a separate table. The table has a column that has an id that reflects the id of the post type so it should always be unique. When I ...
0
votes
0answers
92 views

Remove duplicates from foreach

I'm trying to loop through a custom post type and display all meta values for a meta key. I'm able to display all the values, however there are some duplicates. I want to remove those duplicates. I ...
0
votes
2answers
338 views

Category foreach Paging

I'm using the following code to display categories on my homepage, what I'd like to do is add the ability for paging with previous and next links, I haven't been able to figure out how to do this with ...
3
votes
1answer
93 views

Add Incrementing ID to each paragraph in the_content

I need to loop through each paragraph in the_content and add an ID to each paragraph with an incremental value. function incrementparagraphs( $content ) { for ($i = 0; $i <count($content); ...
0
votes
2answers
136 views

Foreach displays from last to first

I created the foreach loop to display post images, but It displays them from last to first, how can I make It to displays from first to last ;) ? <?php $args = array( 'post_type' => ...
1
vote
2answers
244 views

Apply different Class for each element in a foreach()

sorry for the silly question, but I am really lost. I want to apply the following CSS to the even elements of my foreach. CSS .blogArticles a { float: left; max-width: 250px; width: 25%; ...
0
votes
0answers
72 views

How to filter the terms to a special custom taxonomy?

I do have a custom taxonomy called "countries". With the code below I get for each term (country) the number of its published posts in brackets, like the following: Canada (3) USA (5) Italy (2) ...