The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
16 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
19 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
19 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
19 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
37 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
46 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
53 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
93 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
152 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
2answers
232 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
268 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
68 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
106 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
70 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
43 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
142 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
71 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
92 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
137 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
60 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) ...
0
votes
2answers
27 views

How can I hide my section title if there is no data in custom fields?

I wrote this function with a foreach and I'm not able to figure out how to hide the section title if there are no custom fields in $lista. Where should I place the section title? function ...
0
votes
1answer
59 views

Change page template programmatically inside foreach

i have been trying to attach multiple pages, eash to its page-template using a foreach loop... Manually meaning writing each page code works but inside the foreach loop it wont work. I have several ...
0
votes
0answers
31 views

Edit a custom admin page

I have created a custom admin menu page with: add_menu_page This page uploads a form to the wp_options table in the database. Basic save with update_option like: function addressbook_save (){ ...
0
votes
2answers
101 views

Save checkboxes of a metabox with a foreach loop (invalid argument)

I'm new to Wordpress plugin development and I'm trying to create a list of checkboxes (from a WP Query) to associate as custom fields for a specific post type. Nothing wrong with the display function, ...
0
votes
1answer
561 views

ACF checkbox array is returning numbers, not labels [closed]

I am using Advanced Custom Fields and the add-on Repeater to create a field in the admin through which a user can select multiple icons. Each icon has an associated label, and I'm trying to return the ...
0
votes
1answer
25 views

Why is only the first operation run in my loop - except for on the last repeat? [closed]

We have a custom walker displaying only the sub menu of the current top menu and while making some changes to it I ran into something I don't get - for some reason only the first echo of each loop in ...
0
votes
2answers
225 views

List posts by their custom taxonomy term, with a condition

I have two custom taxonomies called "custom-category" and "file_type". I am using the below code to list all the terms of "file_type" along with their associated posts. Like so: File_Type Term 1 ...
0
votes
1answer
306 views

Display post category in foreach loop with category link

I have the following code to show current author post lists with post thumbnail, post title, post date and post category. function my_get_display_author_posts() { global $authordata, $post; ...
0
votes
2answers
482 views

Display post category in foreach loop

I am trying to display post category in a foreach loop. I have all the elements displaying properly except for the category. Here is my function: function my_get_display_author_posts() { global ...
0
votes
1answer
109 views

Get foreach for meta_query value

How can i get meta_box foreach value inside meta_query value, here is code: $my_id = get_post_meta(get_the_ID(), "artist_name", true); $artistNames = array(); foreach($my_id as $id) { ...
0
votes
1answer
169 views

How can I return multiple image attachments with wp_get_attachment_image_src

I want to return multiple image attachments to my template landing page, but wp_get_attachment_image_src only returns the first image attachment. How come? Thanks in advance <?php /** ...
-1
votes
1answer
70 views

Foreach giving one too many list items, how can I remove the last empty line?

Hello Stackexchange users! I built a simple function to display a list of items from custom fields. However it is listing an empty last field on the front end and I cant figure out how to remove it. ...
2
votes
1answer
141 views

Show list of authors with latest post NOT older than a month

I found two bits of code. One gets me posts NOT older than a month the other bit gets me a list of authors and their custom fields, names, etc. Can someone please help me integrate the two. One runs ...
1
vote
3answers
92 views

get_*_meta doesn't always return an array

I find it annoying that functions like get_user_meta or get_post_meta will return an array if the meta key exists or false if it doesn't. This means I need to do a check like so: $meta = ...
3
votes
1answer
50 views

foreach error on false boolean from get_terms

I'm grabbing an array of page ids that were created in another function which I use regularly- that's all good. The issue I have is in the below function. Some pages have not been assigned an ...
0
votes
2answers
122 views

post__in - Placing content from a foreach loop inside of an array

I know this code is incorrect, but it's a basis of what I am trying to achieve. I am parsing an xml feed via PHP and running a foreach loop to get a value from a specific key. Here is the snippet I ...
0
votes
2answers
568 views

How to use Wordpress Conditional Tags in get_posts foreach loop

I have a page which has a jquery tab function to output the list of pages that are the children of this page (Bio, Archives, Contact). However I am trying to make a conditional in the foreach loop ...
0
votes
1answer
34 views

Store Foreach in user profile

I use a foreach to get visits / visitors per month with Analytics API. I need to store the results in the user profile the way it is displayed with an echo. I tried this but I don't get the right ...
0
votes
1answer
158 views

How can i show pagenavi in my author.php?

With this query in author.php i show all posts from a specific author_id/name/slug. But the problem is when i set the minimum of posts to show in the page. I have tried with posts_per_page= but if i ...
0
votes
0answers
158 views

How to output data from meta box with cloned fields?

Just to let you know, i am at a beginner level with PHP, so please bear with me : ) Also, I looked at this post and I did not find it helpful in my case, so I am making a stab at it here. (Meta Box ...
0
votes
0answers
119 views

JQuery is only applying to first post in loop

I have a JQuery script that creates 'arrows' that allow for my textbox to be scrollable, the problem is JQuery is only apply it to the first post (you can see none of the other posts have the arrows). ...
0
votes
2answers
142 views

Displaying values from related field - if empty shows current post type's link and title

I'm working with custom post types. In the post type awards I have a relationship field that links each award to a post from the post type project. I'm using the following code to return the values ...
0
votes
3answers
131 views

Conditionally set post_content in wp_insert_post

Is it possible to conditionally set the post_content in wp_insert_post? Im using a foreach to add multiple pages at once: foreach ($create_pages as $new_page) { $add_pages = array( ...
2
votes
2answers
194 views

How can i get the last post from wp multisite?

I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each blog_id: <?php $blogs = get_last_updated(' ', ...
0
votes
2answers
83 views

Create menu locations for each category in wordpress

I need display a special menu in each category page in wordpress, for example I have 3 category: horse,dog,cat So I must have 3 menu in Menu Settings locations with name: horse,dog,cat with this ...
0
votes
0answers
32 views

Get_post_meta returns Array instead of actual value [duplicate]

With the PODS plugin in Wordpress, I've created a custom post type called project. Within project I've created a few custom fields. One of those is project_thumb. The thing is; When I want to display ...
0
votes
1answer
75 views

List all pages including archive

I'm creating a custom options page on my site. One of the options is controlling a box on the homepage and i'm trying to set the link for the item to any page on the site via a select menu. as of now ...
0
votes
0answers
25 views

WP supersize not displaying when different languages flags are selected

I've got a very strange problem with this website. The background slides appear when your English flag but when its switched to The Spanish flag or Other flag the backgrounds don't appear. Link to ...
0
votes
2answers
80 views

Order by custom field attribute

I'm try to get the output of this post type to order by the staff name alphabetically and I can't seem to figure out if needs to be within the beginning array() or if I been do something within the ...