WordPress is a free and open source blogging tool and a content-management system (CMS) based on PHP and MySQL.

learn more… | top users | synonyms

-3
votes
0answers
9 views

Warning rTrim () expects parameter 1 to be string [on hold]

I keep getting this error code on my website. I am using a pagebuilder in wordpress. Warning: rtrim() expects parameter 1 to be string, object given in /home2/l4x9p6s6/public_html/wp-includes/...
0
votes
0answers
13 views

Echoing an array of values in PHP? [on hold]

First post here so bear with me... Im working on a projet in Wordpress and just cant get this function to work properly. What I need to do is to assign an ID value to the variable $tour_id. ...
0
votes
1answer
98 views

Custom Homepage

I am job-searching and putting together some code samples. Just wondering how it looks. Here is an example of some code, from a custom WordPress theme, that works and is in production: Homepage ...
0
votes
2answers
51 views

Laravel Wordpress REST API Controller

For a Laravel project I needed to show latest three blog posts on the homepage. The blog was made with Wordpress and after some research I found a cool plugin called REST API that allows to get a json ...
3
votes
1answer
30 views

Moving WordPress database and files to new host

I've written a script in an attempt to try to automate moving hosts from old hosts to our new docker containers. All feedback and input appreciated! ...
1
vote
1answer
80 views

Responsive jQuery menu

I have completed writing a responsive menu (it uses the HoverIntent plugin) for my WordPress theme and it looks like it is working fine on desktop/tablets/phones. You can test the code here. Just ...
2
votes
1answer
51 views

Create JSON file from WordPress ACF options

I am using a WordPress multisite network and want to pull information from options pages in Advanced Custom Fields to create a json file. I currently have this code running whenever an options field ...
1
vote
0answers
40 views

PHP how to build html in class

I am used to procedural PHP. However, I have a piece of code that needs to be repeated a lot. I was thinking of trying my hand at creating a class. All is going well and it is working, but I think ...
1
vote
0answers
27 views

Database table for WordPress plugin

Is there a better solution to create a database table for a WordPress Plugin? How can I simplify this query? What code improvements could be made in this code? Any ideas would be great. ...
-3
votes
1answer
33 views

Correct indentation for writing php array with a long html value in it? [closed]

How would I properly indent this code in PHP (I'm using WordPress)? I'm mostly concerned about how the <button> comes into this equation @ ...
2
votes
2answers
59 views

Re-sorting newsfeed based on date

Background: A client side I made recently has a component that is made from several (20+) rss-feeds, and the feeds are mashed into one using FreshRSS hosted on our servers. For some reason, FreshRSS ...
0
votes
2answers
51 views
2
votes
1answer
27 views

Wordpress downloader and unpacker

Wrote a small bash-script today that downloads the latest swedish wordpress archive , extracts it and writes wp-config.php Would appreciate any feedback that could improve it / prettify it. The ...
1
vote
1answer
42 views

Toggle-able checkbox custom post meta

I have created a basic checkbox custom meta box in order to set a post as "featured". ...
-1
votes
1answer
64 views

I'm not sure if my query is safe or I need an extra step to sanitize data

I'm not sure if my query needs extra steps to sanitize data to prevent SQL injection. If I use $wpdb->get_results($query), do I need to ...
1
vote
0answers
67 views

Converting CSV To MYSQL With PHP In My Custom Wordpress Plugin

I have a function which converts a file from CSV to MYSQL The file could be 5,000 rows long up to 90,000 rows long. Based on ...
2
votes
1answer
43 views

WordPress - meta description

Here's the code I'm planning to use to power meta description tags for a site in header.php in the template. Is anything missing / incorrect / could be done better? ...
4
votes
1answer
37 views

Looking for meta data which matches certain criteria and was created after a certain date

I've got the below SQL statement which runs in MySQL on a WordPress installation. I'm looking for meta data that matches certain criteria and was created after a certain date. However, WordPress ...
4
votes
0answers
79 views

Object-oriented WordPress plugin

Note: This plugin is / was never intended to be submitted to repo just for personal use but the questions still apply to general Plugin Development. This plugin listens for ...
3
votes
1answer
106 views

Singleton Class for WordPress Plugin

I'm developing a WordPress plugin using the singleton pattern with the following requirements: There should ever exist one instance of the plugin Another instance of the object should never be ...
3
votes
1answer
94 views

Bootstrap WordPress Carousel Recent Posts

This works, but I would like suggestions to improve it. For one I think the get posts shouldn't have to be repeated twice, but it only pulls the first two posts if I don't do it this way. Also, I ...
9
votes
1answer
64 views

Automating a WordPress install

I do not have a whole lot to do over winter break, so I wrote this little script to automate a Wordpress install (currently can only install once instance) on a fresh Debian server (tested, working ...
3
votes
1answer
49 views

Making a grid of videos

In my single-work.php I have some code with slight variations that I feel could be more DRY. When there are only slight variations like this is it ok to repeat part ...
4
votes
1answer
42 views

Adding Wordpress Meta boxes

I am adding two custom metaboxes to the WordPress post page from a plugin. I am currently doing it with two separate instances of add_meta_boxes but this feels very ...
1
vote
0answers
61 views

Hopefully secure post love counter

Is my nonce implementation secure? I'm trying to learn security on wordpress->ajax (and later woocommerce) and with wp_create_nonce. After much struggling I managed ...
2
votes
1answer
73 views

Compare multidimensional arrays

I'm writing a wordpress plugin that makes changes to the admin menu. To add some context: The wordpress global $menu is a multidimensional array. Each array in <...
6
votes
1answer
45 views

Determine value in range, inject to HTML to be used in CSS

I want to show users what package they are, based on how many items they have in their cart. The code works, but I'm wondering if anything can be improved. ...
7
votes
2answers
102 views

Recursive download articles and dump to MongoDB

This is simple code that recursively downloads articles from the public WordPress API: ...
2
votes
2answers
46 views

Saving array values for a secondary foreach loop

Although used within the WordPress platform, this is PHP focussed question. I have an array of child posts, some have content, some don't. My client wishes to display the posts in alphabetical order, ...
0
votes
0answers
56 views

Front-end login system

After some googling for about 2 days, I am here with a simple wordpress front-end login system. Please let me know if there is anything wrong with it, or if there is anything I can do, for improving ...
4
votes
1answer
103 views

Add user profile fields

I have this PHP function that adds custom user profile fields to WordPress. It saves the field through the WooCommerce form-edit-my-account.php file. I have a lot of repeated code, and would like to ...
3
votes
1answer
30 views

Bash Compress Managed Directory Ignoring .git, bower_components, node_modules, etc

Fairly easy way to compress a wordpress plugin (or similar) as a zip file without including all the dependencies used to create and manage the development, but which don't belong in the final product. ...
3
votes
2answers
129 views

Inserting a name into a database table

I want to ask you if my PHP code is safe enough. I don't know if I should escape special characters in string after regex validation: ...
3
votes
1answer
36 views

User generated filter and content

I am writing a (multi) filter that is created when the user enters in the data through wordpress. There can be anywhere between 2 - 10 filters so I need this to be as dynamic as possible. My first ...
3
votes
1answer
103 views

WordPress anti-spam script

This is the first PHP script I have written. It downloads and installs a plugin called "anti-spam" by using the WordPress API. It also provides an option to either delete all comments or delete the ...
2
votes
1answer
55 views

Listing links for categories

I've developed some PHP that grabs all of a business listing's categories and then displays just the children categories. This is built on Wordpress. I'm still in the learning process and would ...
5
votes
1answer
134 views

Related links for WordPress posts

I have written the following class which is part of a pagination system in Wordpress. The class works as expected and also works as expected when used in the system. Just as background, the class ...
2
votes
0answers
19 views

Limiting WP user's access to the amount of credits they have

I like this solution but maybe there is another way. My goal with this is to limit user editing to the amount of credits they have. What do you think? Here is what it does: Credits are stored as ...
2
votes
2answers
247 views

PHP function (in WordPress) echoing HTML

I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
1
vote
0answers
36 views

Time table for users

I'm working on a WordPress theme and creating a time table which will be easy to complete by users. In the back-office, there are a checkbox for each days: ...
1
vote
1answer
33 views

Multiple Wordpress metaboxes in fewer different functions

Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields): ...
1
vote
1answer
128 views

Interface injection and common functionality between classes

I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These ...
2
votes
1answer
123 views

Reading and Converting XML File to Array

I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
6
votes
2answers
552 views

Checking for existence of URL parameters

I'm busy rewriting some from my spaghetti code into OOP classes. I'm still learning OOP and very new to the concept. From help from this answer from @EliasVanOotegemto on a previous question I've ...
3
votes
2answers
226 views

Sort by a custom date field

I've got this code to work, but being really new to PHP, I don't know if this is proper. I've sorted a CPT loop by a custom date. I'm displaying items from most recent (or future date) to oldest if ...
3
votes
2answers
224 views

Correctly coding an OOP object

I have a couple of functions in WordPress that I'm rewriting to OOP. All these functions are interlinked in some way and also reuse code from other functions. This is an example of the first class I'...
1
vote
1answer
466 views

Button to follow / unfollow a user

As a beginner in coding, I have just written this code. The code should Add a form with a button to each user profile, it named Follow or Unfollow. It updates the user meta named "following" for the ...
2
votes
2answers
69 views

WordPress: multiple loops

I have two loops on my page - each with their own category. It works, but I don't know if this is the best practice as I'm pretty new to this stuff. ...
2
votes
1answer
157 views

Navigating calendar by week

I started actually learning a little programming last year, as opposed to just hacking away at libraries and found fragments. For a WordPress plugin I needed to navigate through weeks, which I ...
2
votes
1answer
477 views

Removing stray brackets from in between shortcodes

I was wondering if someone could point me in the right direction for cleaning up this code. WordPress uses shortcodes in the form [shortcode] to add extended functionality to posts and pages. What ...