All Questions
29 questions
139
votes
15
answers
610k
views
How to get URL of current page displayed?
I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use echo get_permalink(), but that does not work on ...
2
votes
2
answers
581
views
Guidance with The Loop for CMS
Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 ...
24
votes
2
answers
59k
views
Query multiple custom post types in single loop
I'm aware there are several other posts that cover similar ground to what I'm about to ask.
I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts ...
8
votes
1
answer
6k
views
How can I fetch loop of post titles via AJAX?
I have a list of the most recent post titles in sidebar.php. Here is an example of how that code looks:
<?php $args = array('posts_per_page' => 20); ?>
<?php $sidebar = new WP_Query($args)...
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(
...
11
votes
1
answer
16k
views
What is This esc_html_e() i wordpress php?
why do developers use
<?php esc_html_e() >?
in 404 pages, what does it mean, how does it works?
6
votes
1
answer
1k
views
Inject post (from specific category) between posts in Loop
I would like to add a post (from specific category) between posts in the WordPress Loop (such as 'Sponsors'). Example:
P P P S
P P S P
P S P P
How can I achieve this? I am a beginner with coding, so ...
4
votes
1
answer
33k
views
get product attributes for current product and store it in a variable
Been trying to figure out how I can get the product attributes of the current product and store it in a variable and put it in a class.
I've managed to get the product attributes, unfortunately it ...
4
votes
2
answers
1k
views
Build a content and excerpt grid loop with paging and options for # of posts
What I'd like to do: on index.php, a loop that shows a selectable number of full posts using the_content and then below that shows a selectable number (the number of posts can be hardcoded in the ...
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
2
answers
164
views
Want to separate sections of posts. Can you restart loop?
I want to break the loop into sections of posts so I can put content in between that doesn't repeat. Is it possible to end the loop and restart?
My code works for my layout works if there are 10 ...
1
vote
1
answer
1k
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
vote
2
answers
6k
views
Specific Loop For 2 <div> Within Each <li>
I need to create a loop that can logically be described as the following for a carousel:
Requirements:
3 Loops
2 Posts Per Loop
No Duplicates
Order by Post Date
Visual:
< Start Loop #1 >
<...
0
votes
1
answer
40
views
Custom post type loops with different page templates
My website has two different page templates. Each page template contains a different custom post type. The posts from the loops can be loaded by AJAX to load more.
This is the common code that I run ...
0
votes
1
answer
154
views
Print html when custom field has value inside while loop
I want to print a block of HTML only when get_field('cennik_title') has value assigned to it inside the loop, when there is no value inserted inside the custom field, the block should be skipped, but ...
0
votes
1
answer
591
views
Alter secondary loop to exclude posts from current page category
The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude ...
0
votes
1
answer
643
views
MySQL query performed 4 times inside loop
I have enabled custom php in my pages through the use of the exec-php plugin so I can run more complex pages than the standard WordPress page. I have had no problems with this plugin so far.
I have ...
0
votes
0
answers
49
views
delete an array element when its date expires
I have user levels for access content. I made a start date and end date input for each other. Each level has its own history. Whichever level date exceeds today's date, it will be removed from user ...
0
votes
1
answer
2k
views
List events by month
I am working on a WordPress site consisting of a custom post type called "events". Each "event" consists of a custom field called "event date". I'd like to organize all the "events" by months based on ...
0
votes
2
answers
751
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
4
answers
13k
views
How can I loop into two different DIVS without repeating the DIVs
I am having a little trouble trying to figure out how I can accomplish this: I have a container with two colums in it, a right and a left column. Each column will have 3 posts with a short excerpt ...
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); ?>...
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
2
answers
659
views
Custom Loop Pagination on WordPress
I'm trying to create a magazine style website. For this particular page (not homepage) I'd like to fetch the latest post and style it one way (style1). For all the other posts I'd like to just display ...
0
votes
1
answer
3k
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 ...
0
votes
1
answer
565
views
Post from one loop in different containers?
Is there a way to output posts from a single loop in multiple containers?
Ideally I'd like to have the posts title/meta/content etc alternate between first-container and second-container, but I can't ...
0
votes
1
answer
196
views
Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin - Adding to "Thoughts" Theme
How do I enable infinite scroll (either with the infinite-scroll plugin OR the built in infinite scroll jetpack) on the "Thoughts" Wordpress theme?
I'm a total noob at editing this stuff so if you ...
0
votes
1
answer
4k
views
How to add active class to custom menu using while loop and wp_list_pages
I am running wp_list_pages through a while loop to create a custom menu. By running it through a loop I can target specific elements to show. I need to figure out how to either target the classes ...
-1
votes
4
answers
3k
views
Two posts in same div - WP loop
I would need the following in Wordpress:
<div class="posts-wrapped">
<div id="post-1" class="post">
<h1>Title 1</h1>
</div>
<div id="post-2" class=...