All Questions
411 questions
0
votes
1
answer
42
views
Div Missing In Custom Loop Query
I'm using a customized php code for my wordpress loop. The code is designed the break the post up to be styled differently via html & css. The code is also designed so that I can add div blocks in ...
0
votes
2
answers
979
views
Assign custom parameter to each post in query
I'm trying to add an incremental variable to each post that comes up in a series of queries. The purpose is to calculate a weight for each result in order to be able to order everything later.
This ...
0
votes
1
answer
35
views
Wordpress query posts by custom post type not workng
I'm trying to display the featured images of my custom post type of 'instrument'
I created the custom post type using the plugin 'Custom Post Type UI'
The query seems to work, but the problem is ...
0
votes
2
answers
3k
views
Conditional in foreach loop is outputting content twice
I have a website that displays a slideshow using custom fields and the Slick carousel, using the code below.
<?php $entries = get_post_meta( get_the_ID(), '_mysite_homepage_slider_group', ...
0
votes
1
answer
3k
views
Add post class in custom loop (WP_QUERY)
Normally if I wanted to add a custom post class I would use the post_class filter.
However, when using a custom loop the post_class filter is not accessible.
I am trying to apply classes that will ...
-1
votes
1
answer
21k
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
2
answers
6k
views
How to wrap every 3 posts in a div (and close the last div too) [closed]
I have code that wraps every 3 posts in a div (so that the posts will line up horizontally even if different heights). It closes the div after 3 posts, but the problem is the div is left open if there ...
0
votes
1
answer
890
views
Dividing the loop to style post differently
I'm using a plugin that displays post and shows them in a certain area on my site, such as the sidebar or anywhere i put the <?php;?> code, but only if the author that is writing the post clicks ...
1
vote
1
answer
180
views
Wordpress Search Results for Multiple Post Types
I want to show both posts and attachments in the search results. Basically, I need something that says if the post has a thumbnail, show it. else show the attachment image (since they don't have ...
2
votes
3
answers
1k
views
Wordpress loop specific thumbnail size
That's my loop:
<main id="main">
<?php
// the query
$args = array('posts_per_page' => 10 );
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query-...
1
vote
1
answer
185
views
How can I add pagination and how can I change thumbnail size?
I'm currently learning wordpress development and I try to add pagination which displays a "older"/"newer post" link and the number of the current page at the bottom of the posts. I also try to change ...
0
votes
1
answer
4k
views
How to change post count in wordpress loop?
Hey I am attempting to customize my WordPress post loop to create different post styles for a certain set of posts.
For example the first three posts would be styled in it’s own way, the next four ...
0
votes
1
answer
100
views
Loop 1 user randomly
At the moment I am using wp_user_query to loop users from a specific role(leden) on a webpage. For the overview page this is working fine, but on my homepage I want to feature one random user.
I was ...
1
vote
0
answers
584
views
Display category name only once inside loop
I have been researching on how I can output the category name on a wordpress loop for custom post only to display only once. If there are any posts under the same category, the category name will not ...
-2
votes
2
answers
1k
views
How to create a loop where loop changes every post?
How can I create a type of loop in WordPress where an image moves left or right for each post? I.e. first post image will be left, second post image will go right, third post image will go left, and ...
-2
votes
2
answers
2k
views
How to create a loop that will display one post and stop?
I am trying to create a part on my wordpress theme that will only display one featured post. I have installed this plugin - https://wordpress.org/plugins/featured-post/ .
I know I am supposed to ...
-1
votes
1
answer
3k
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 ...
0
votes
1
answer
185
views
Create a hierarchical loop at predefined markup requirements
I try to achive this in wordpress based on my theme:
fullpage.js demo
So I have a predefined markup for vertical sections (parents) and one for horizontal slides (children). Parents only contain ...
0
votes
1
answer
818
views
Display only text to WordPress loop without loosing the text formatting
I want to display text from content (only text) with the formating (paragraph, bold, italic.) on loop.
When I am using this code:
<?php echo mb_substr( strip_tags( get_the_excerpt() ),0,255); ?>...
2
votes
1
answer
120
views
How to append element after thumbnail
Hey I just wanted to know how to add an element after the first thumbnail image in my loop. Basically I want an HTML div tag inserted after the first image in my post. Anyone know how to do that in ...
3
votes
1
answer
1k
views
Displaying post per day
Currently I have the code displayed below.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<a class="...
1
vote
0
answers
342
views
Can't find infinite loop cause
I am working on the below function which will eventually create a set of posts based on meta data entered into a "parent" post. I'm running into an infinite loop when hitting the save button, which I ...
2
votes
0
answers
1k
views
Custom Loop through category menu to include sub categories
In my custom wordpress theme I currently have the below loop to the main categories
<?php
$menu = wp_get_nav_menu_object('navigation');
$items = wp_get_nav_menu_items($menu->term_id);
foreach($...
1
vote
1
answer
112
views
Checking array against author id in loop
So I have a function in Wordpress with a plugin that returns a list of friends as an array. The function code is here:
function friends_get_list($tmp_uid, $friend_status=1) {
global $wpdb;
$...
0
votes
1
answer
66
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
2
answers
113
views
Must Use Plugin Causing Query Error
I created an MU Plugin which will only display the posts from certain tags in the loop like this:
function custom_tags( $query ) {
$query->set( 'tag', array( 'custom', 'general' ) );
}
...
2
votes
1
answer
597
views
Displaying Only Certain Tags in Loop
What I'm trying to do is alter the loop across my site so it will check the site URL so it will know which tag to display.
For example, if I give some posts the tag "golfclubs", I want it to work ...
1
vote
2
answers
49
views
How do I Turn This Into An if statement?
PHP noob here. I've got this query I've written to get the information of all child pages of the page you're currently on:
<?php
$pages = get_pages('child_of=...
0
votes
1
answer
47
views
enumerating custom taxonomies?
I made this function that displays tags as an image grid
function execute_taxography() {
$wpbtags = get_tags();
$output.= '<div class="grid"><div class="taxography-grid"><ul>...
0
votes
2
answers
2k
views
Get post id within comments loop
I have a custom comments loop on my author.php page. I am trying to get the post id so that I can echo the permalink for the post that the comment belongs to. Also so I can echo some post meta custom ...
0
votes
0
answers
34
views
Loop returns more items than exist?
Using the answer here: https://wordpress.stackexchange.com/a/207601/45709 exact works as it is intended. It returns 3 slides because only three slides exist. I had to slightly modify the code because ...
1
vote
1
answer
585
views
How to loop over custom fields in a page template?
I was originally using a single field and things worked perfectly with the following code. Now I need to alter it to loop of several fields that are similar.
To start: I've created several custom ...
1
vote
1
answer
365
views
CPT + CMB2: data not displaying for only first post in loop
I've a CPT incorporating CMB2. I loop through every category and show each post within that category. My issue is that the first post in each category doesn't display certain info from two metaboxes: ...
0
votes
1
answer
193
views
Using page template to fetch posts in page
i want to display posts in wp page. to do that this is what i did i created a template named mypage-page.php and copied code from page.php to mypage-page.php
this is my mypage-page.php
<...
0
votes
1
answer
3k
views
Store post content in a php variable and output them using for loop
I want to show the content of my post in a separate row one at a time whenever a tab is clicked. I already achieved this but the problem is, its showing the output for only the last tab. Other tabs ...
1
vote
1
answer
7k
views
Create a random unique 6 digit number as custom field for custom post type
I use the following function to create a random unique 6 digit number and save it in a custom post type meta field.
I am unsure about the use of rewind_posts() inside a while loop. The idea is that ...
0
votes
1
answer
627
views
Limit tags shown in post
How do I limit the number of tags shown using the code below, without having to add $count=0; or if ($count <= to the query, but only for the home page, and a different number for each set of post?...
0
votes
0
answers
441
views
Modify category archive page loop on functions.php
I was able to modify the query on the category archive page using
global $wp_query;
$args = array_merge( $wp_query->query_vars, array(
'tax_query' => array(
array(
'...
0
votes
1
answer
6k
views
How to add div blocks after certain set of post
Ok I broke my post down into different style settings. Like shown below. The first post is a large block. the next four post are small and aligned next to the larger post.
I used the loop below to ...
0
votes
0
answers
81
views
Custom Taxonomy Link Text Echo Name Not Slug
I'm a little lost about where I can place a simple php echo within a loop.
I have a "program" taxonomy where each program is echoed onto buttons. Right now I'm only echoing the slugs for the link ...
1
vote
2
answers
2k
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
1
answer
2k
views
Echo a shortcode div after every 3 posts
In my wordpress home.php file, I have placed an increment loop with the help of a few stackexchange threads:
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (...
0
votes
1
answer
124
views
WP_Post is not from correct array
A bit of a complicated problem here, but I figured I'd see if I could get any help.
My logic is this:
WordPress custom post query > for each of the results, factor in distance (calculated separately)...
-2
votes
2
answers
284
views
Woocommerce linking variations
So I have this array (just taking an example, it's dynamically built up):
$v_values = array(
array("C1","C2"),
array("F1","F2")
);
$v_name = array("color","...
0
votes
1
answer
2k
views
Wordpress call post-ID in jquery
I explain the situation I'm having here:
On my home page, I have a list of post being display.
I've code to have like a modal box to share this post. Basically, on each post you have a button share. ...
0
votes
1
answer
33
views
Post formating on Home page
I've simple question regarding WordPress post looping.
I want to achieve something like this on my site:
~ I am running Real estate portal site and I want to display featured property on my home ...
0
votes
1
answer
48
views
How to avoid duplicates when creating recent network posts
I'm using this code to get a list of custom posts (with custom fields) from the network for display in a php widget. It's old, but it's working fine:
<?php switch_to_blog(4); ?>
<?php $ca = ...
0
votes
2
answers
945
views
divide custom field values in div every two values
i have this html mark-up to sort some data
<div class="row">
<div class="col-xs-2">
<img src="images/member-schools/ms1.jpg" class="img-responsive">
</div>
<div class="...
1
vote
1
answer
111
views
Changing layout with wp_customise
So I'm trying to build a conditional statement to display different layouts depending on the option selected.
Having a bit of trouble.
$wp_customize->add_setting('layout', array(
'default' ...
0
votes
1
answer
650
views
Create Customization Controls from Array
Coming from a Javascript background and humbly jumping into WP dev I'm having some trouble with PHP (especially in a WordPress context).
Here's what I'm trying to do:
Create controls for the ...