All Questions
410 questions
0
votes
0
answers
11
views
Trying to change the default page break numbering format
You provided an answer on the below post, I wanted to ask if this should work on Wordpress posts or pages, Im trying to do something similar for posts but I added your code to functions.php and it ...
0
votes
0
answers
12
views
Issues applying JSON body filters in EU F&T Portal SEARCH API with WordPress integration
I am trying to use the SEARCH API service of the EU F&T Portal public REST APIs for retrieving data for further integration with my project, but I am having some problems. I am using WordPress as ...
1
vote
2
answers
18
views
Category Attachment Pagination 404 Error on 2nd Page
I'm customizing category.php to display all attachments with a specific category, but when I click on a link for a page besides the first one, I get a 404 error. To reproduce:
Install a new Wordpress ...
1
vote
2
answers
257
views
Warning: Undefined variable $post_id
Hi can anyone please help.
I'm no computer buff and need a step-by-step guide if possible.
In getting this error on my product pages:
Warning: Undefined variable $post_id in /customers/5/f/d/...
0
votes
1
answer
59
views
How to display only the first 2 words of a post title
I am learning WP and want to display only the first two words of a post title to the user. For the end user only the first two words of the Post title (H1 class) should be shown but source should have ...
0
votes
0
answers
34
views
How to get ACF field to show up on all posts on front end?
I have thousands of posts with attached files. These attached files are part of Advanced Custom Fields Pro. However, they are not showing on the front end for the posts.
These files are utilizing the ...
0
votes
0
answers
20
views
Global update of records after import WP All Import Pro
friends. I have encountered a problem updating records.
I am importing vacancies into the WP Job Board Pro plugin via the WP All Import Pro plugin.
When importing, I have a field in wp_postmeta ...
0
votes
0
answers
38
views
Display posts based on the selected category when no subcategory is chosen
The following code displays posts based on subcategory. First dropdown is a custom taxonomy category, second dropdown narrows down the search to subcategories associated with selected category. My ...
0
votes
1
answer
273
views
How to change post date and post time in Wordpress automatically with a function
I am not much of a coder but I have done research lately on how to change the post date and time in WordPress to the current date and time for all posts and I have not been able to get much.
If anyone ...
0
votes
1
answer
172
views
Display two previous posts on single.php
At the bottom of single.php, I want to display "card" links to the next and previous posts in chronological order. This is pretty easy thanks to get_next_post() and get_previous_post, no ...
0
votes
0
answers
25
views
Updating post_parent caused the website to become unresponsive for 40 seconds or more
I am building a WordPress plugin the sets the post_parent of a post to the id of a custom post type called series. However, once I click update on the post it successfully updates the post and the ...
0
votes
1
answer
39
views
is_singular() in mu-plugins not working
I wanted to use mu-plugins to load the plugin only on a page with a single blog post. Unfortunately, the is_singular('post') function is not working properly. So I tried using $post->post_type, but ...
0
votes
0
answers
111
views
Bulk data save in custom table
I have a form in admin page that store data in custom table, with multiple checkboxs.
On form submit I need to save the checked box id with the store id it's related in a key pair way (store_id => ...
1
vote
2
answers
266
views
How to use a conditional statement in a post loop but not count towards the "posts_per_page" if false
I have a WP_Query which has the "posts_per_page" parameter set to 12. I am then using a while loop to iterate over all of the posts and an IF statement to check whether a condition is true ...
0
votes
1
answer
258
views
Count the number of matching post names in foreach loop
I have a simple foreach loop that outputs an ordered list from a CPT 'post_subscribers' and an associated meta key called 'project'.
$theposts = get_posts( array(
'post_type' => '...
0
votes
1
answer
501
views
Need Help With Making Full-Width Template for Blog Posts (common methods aren't working)
I've been researching this one for a while and can't seem to find the solution. But, I'd like to have a selectable template that I can use for certain blog posts to make them full-width by not ...
0
votes
0
answers
245
views
transition_post_status hook, works - but not if the post is new
I have no idea whats going wrong. My transition_post_status function works if the post is saved as a draft or another status first, then saved again as the 'transferring' custom post status, which it ...
0
votes
0
answers
43
views
How do I get a function to work in single.php
I have a code.
add_action( 'init', 'njengah_change_post_date_programmatically');
function njengah_change_post_date_programmatically(){
$time = current_time('mysql');
wp_update_post(
array (
...
0
votes
1
answer
33
views
Set post to draft if matching word is found in the post
Not sure what exactly I'm missing here but I'm trying to set a post to draft if one of the words are detected, it will only publish the post if the user removes the word found within the post. At the ...
0
votes
1
answer
148
views
Disable single posts, but keep archive
I need to completely disable single post pages, but keep the archive. I don't only want to remove the links from the archive, but fully disable the single post pages, so that they cannot be reaced by ...
0
votes
2
answers
98
views
Blog Posts not sorted and pagination not adjusted after filtering some category
Hello im really stuck and messing around now so i thought i give a try and ask the community.
Im working on a Blog Post page where im showing some posts. The user have the selection to search for ...
0
votes
1
answer
770
views
Add multiple HTML attributes to an Elementor button
I want to add multiple HTML attributes to a button which is present across all blog posts on my website. The buttons all have links in them, to which I want to add like 3-4 'rel' attribute values. I ...
0
votes
1
answer
26
views
WooCommerce: write featured image dimensions to custom fields in product'
It's all in the title. I'm somewhat handy with php, less so with WP hooks and subroutines. When I originally select (or later change) a featured image for a product, I want the pixel dimensions of the ...
0
votes
2
answers
140
views
Prevent post from being published and show error
I'm trying to prevent a post from being published if it contains certain words using the folowing:
function jhnppWord($content)
{
global $post;
$content = $post->post_content;
$...
1
vote
1
answer
411
views
Wp Query : Order by distance lat,lon
I'm new to this forum, sorry in advance :)
I have a problem with my display of my posts
Let me explain ^^
I want to perform an orderby => '$distance' and display the posts accordingly.
$lat2 and $...
0
votes
1
answer
816
views
Pagination in single.php
I have a problem with the pagination on a single.php page.
The idea is to have a list of my created posts (the excert, the title and a link to the post) on the post page (single.php) that shares the ...
0
votes
0
answers
174
views
redirect after submiting post for review
I have a frontend page that allows "Tutor Instructor" role, to create a course and this course is a custom type post called courses, when the Tutor Instructor finishes creating the course he ...
0
votes
0
answers
245
views
Add posts to custom table in database instead of wp_posts
What the code does:
Imports posts, loops through all the posts and calls wp_insert_post to create a new posts for each import.
Objective:
Import posts and store them in another table, not under the ...
0
votes
1
answer
367
views
Automatically add images to a menu
I am calling a menu into a page, but I want to add images next to the title of the menu items.
I have this code:
<ol>
<?php
$navMenu = wp_get_nav_menu_items(2096); /*/Pass Nav Menu_id or ...
0
votes
1
answer
70
views
Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
I installed latest XAMPP & extracted latest WordPress
to this path: C:\xampp\htdocs
I activated default theme: Active: Twenty Twenty
I created these:
1 Page called test: http://localhost:82/...
0
votes
1
answer
485
views
Why is a wp function used in current PHP namespace's callback not resolved to global scope?
Imagine the following script:
<?php
namespace MySpace;
class MyClass {
public static function execute() {
// Do something
post_exists(1,'','','my_post_type');
}
}
?>
I'm now ...
0
votes
0
answers
140
views
get value from get_post_meta then reuse it in another get_post_meta
I am writing the following code, which I have updated since the original question so as to give the entire picture. I am a newbie, and the reason why I am not using the get_posts() function in ...
0
votes
1
answer
400
views
Load Posts on Click via Ajax into a DIV
Is it possible to load a specific amount of posts on click into a DIV via ajax?
I've found a lot of tutorials, but all of them make use of the load-more- / next-page-functionality of a theme.
What I ...
0
votes
1
answer
132
views
How to catch wordpress post ID when it's published
I am trying to either automatically a forum section when a post is published - like a discussion page. Normally, I wanted to make the users create the topic but I realized a forum category with many ...
0
votes
1
answer
94
views
understand what code is doing when prepending /blog
I am new to Wordpress and php coding.
We are moving from a different container system to wordpress and to keep the links intact I need to prepend /blog to all post articles.
I tried it through the ...
0
votes
1
answer
95
views
How to show categories and date on posts
I want to categorise posts and show them on my WordPress website. So in order to achieve that I've written a code. My code is below.
function wpb_postsbycategory() {
// the query
$the_query = new ...
1
vote
0
answers
40
views
Unreadable pagination
I act according to the Output of posts
There is a file blog.php
<?php
/*
Template Name: Myblogpage
*/
?>
<?php get_header('third'); ?>
<!-- Content
==========================...
1
vote
0
answers
20
views
200 Rewrite blog post links
I have an self-hosted website and Wordpress where mywebpage.com is my main site and mywebpage.com/blog is my Wordpress Blog.
I'm building an new website on AWS Amplify with more modern web languages, ...
1
vote
1
answer
197
views
Automatically add custom CSS to new posts using a category template
I have inherited the task of modifying a Wordpress site (using a child theme). I'm a designer, not a code or back-end expert.
I have been customizing a set of pages on a site to have alternative ...
0
votes
0
answers
176
views
Generating 10 000 Wordpress posts using PHP and avoiding Server Timeout error
I hope someone would be able to help me. I'm currently trying to develop a plugin which is able to generate 10 000 WP posts, each with different number (basically, 10 000 posts which title is a ...
0
votes
0
answers
17
views
My worpress search page is showing no results
I want to display the publications searched for via searchform.php in the search.php page but it does not work ...
The search is done well when I look at the url (ex: New World):
http://localhost/?...
0
votes
1
answer
559
views
set post limit at load more ajax wordpress
The site has load more posts functionality using ajax on vanilla javascript.
Ajax:
postData.append("action", "loadmore");
postData.append("paged", section_posts);
...
1
vote
1
answer
625
views
If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
I need a way to inform visitors if the post published date or modified date is older than 1 year and if so, display a message on the post page.
I have added an code to my content-single.php file, but ...
0
votes
0
answers
35
views
Is it possible to get the specific content on the search page?
I am working on the WordPress search. I am using the below code to get the data on the search page.
$s=get_search_query();
$args = array(
's' =>$s
);
$query = ...
1
vote
1
answer
831
views
duplicate posts with ajax load more wordpress
I have ajax loading posts on my site when scrolling. The problem lies in the appearance of duplicate posts. I cannot understand why this is happening. Only some posts have duplicates. Here is my code ...
0
votes
1
answer
116
views
Returning data instead of echoing/printing
New to WordPress (and PHP) and am trying to get this PHP snippet to work with the Code Snippets plugin so I can display all media attachments within my post. It is working, in that it shows the ...
0
votes
0
answers
369
views
Filter wordpress posts without searching the keywords in the post content
We've a courses website where we want to filter posts/courses by the keywords present in the category and/or title. Currently when filtering, the keyword is also being searched in the post content ...
0
votes
0
answers
34
views
Why is my custom post content only viewable when signed into Wordpress?
I've created a custom Post type called 'Data' to display content on a Wordpress site. The content works and is displayed if viewed when signed into Wordpress. Howevever, if you view the same URL when ...
0
votes
2
answers
267
views
Posts sortable column not sorting properly for custom field numbers
I have a custom field for view counts that are stored as numbers. I added a Views column, and made it sortable, but they are not sorting properly.
The results when I click on the Views column are ...
1
vote
1
answer
778
views
Build A Custom SQL Query for WordPress Search
I was working on a code, where I used SQL to find something on my site.
I realised that the SQL was giving me far accurate search results, and wanted to implement the same in my WordPress search query....