Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

0
votes
1answer
31 views

Error inserting into custom table - Object of class wpdb could not be converted to string [closed]

Getting the above error when trying to insert into custom table .I am unable to find out what is the cause of the error. The error comes at line 17. Any help is greatly appreicated. The code is ...
0
votes
0answers
28 views

Pagination - Previous link is not show and Next link sticks at page 2

The code below is not able to show the pagination correctly Previous link is not able to show Page 1 is not a link Next Button always sticks with page 2 Thanks <?php if ( have_posts() ): ...
0
votes
1answer
32 views

Access to “My Site” is missing from the admin bar

You know there´s a direct access to every wordpress site right on the left side of the admin bar (or tool bar) once you get access to the wp dashboard which is intended to connect your website backend ...
0
votes
2answers
16 views

adding or removing endforeach; throws error!

This is my code, where i keep getting either error: unexpected endforeach; if endforeach is used or unexpected end of file if i don't use endforeach; It's driving me crazy!! <ul id="portfolio-...
1
vote
3answers
98 views

How to use $_GET function Wordpress backend

I use Plugin Boilerplate for my project. I searched the internet and read all the questions but I couldn’t find what I need. I also read the WordPress Codex. I think I couldn’t get the idea. I have ...
0
votes
2answers
13 views

Unable to insert current username into custom table through html form

I have a custom html form from which I am trying to insert records into a custom table .My problem is getting the current user name and inserting that value into the custom table. When the user clicks ...
0
votes
0answers
9 views

redirect to parent page editor after Gravity Forms editor 'Updated'

I am wondering how; in Wordpress CMS, PHP, and Gravity Forms plugin.. I can hit 'Update' after editing my Gravity Form... and instead of the editor page refreshing after the save/update (current ...
0
votes
1answer
12 views

add 'publish metabox' to Gravity forms edit page/form area

I am trying to add the same 'Publish Metabox' that is on top right sidebar of normal Wordpress posts and pages. Any thoughts? I just tried adding this'add_meta_box( 'submitdiv', __( 'Publish' ), '...
1
vote
1answer
16 views

Custom form action to handle data inside a plugin

This is a stupid question, but I don't have much experience in the wordpress development. If I have a custom form that need to interact with a custom plugin, how I can get the submitted user data ...
0
votes
0answers
7 views

Display front-end page of a custom plugin to manage forms

I've a simple question about plugins. I want to use an external php library for a plugin that I want to use to manage custom forms in wordpress. In my experience with wordpress, I've learned that I ...
0
votes
2answers
47 views

Only allowing some emails to create an account [closed]

I am creating a website that would need to only allow some specific email addresses to signup . An example of this would allowing all emails ending in "@uniname.ac.uk" but not allowing any "@gmail....
0
votes
0answers
11 views

Logo custom width not implementing

add_theme_support( 'custom-logo', array( 'height' => auto, 'width' => 200, 'flex-width' => true, 'flex-height' => true, ) ); and function ...
0
votes
1answer
28 views

Check if post visited first time

How to check if post visited first time? If post already never visited by nobody.
0
votes
1answer
33 views

Enqueing External JS on the remote server JS

wp_register_script( 'custom-js', 'https://s3.amazonaws.com/codexo/custom.js', array( 'jquery' ), '1.1', true ); wp_enqueue_script( 'custom-js' ); Above is the function through which I am ...
0
votes
1answer
42 views

Trying to modify content.php

I am trying to tweak the bootstrap basic theme so that it shows excerpts. It does it when using search but not by default. I am trying to figure out what I need to change on the content.php file. ...
0
votes
1answer
37 views

Fatal error: Uncaught Error: Call to undefined function get_header() [closed]

Fatal error: Uncaught Error: Call to undefined function get_header() in C:\xampp\htdocs\allegiant\index.php:1 Stack trace: #0 {main} thrown in C:\xampp\htdocs\allegiant\index.php on line 1 I ...
0
votes
0answers
22 views

How to use a PHP file to control the content of a blog post

Let's say I've created a page with the ID 62. If I then create a PHP file named page-62.php, I could edit my page from there. I want to do the same with a blog post. How would that be possible?
0
votes
1answer
19 views

Meta inserted through wp_insert_post gets messed up

I'm extending the Woocommerce Product CSV Import functionality to import more data. I'm inserting a CPT with 2 metadata, a string (URL) and a bool, and the post_meta inserted gets messed up. It ...
0
votes
0answers
18 views

Modifying the post pagination next to redirect to another webpage

Heeey everyone I am using a break page on my posts, so that my long posts can be cutted into 3 different sections, each one will be shown after a click on the next button what I want to acheive is ...
0
votes
0answers
36 views

Allowing Non-Latin Characters In WordPress Registration

There exist a plugin for wordpress to enable usernames containing special characters (Russian, Cyrillic, Arabic …). Unfornetly this plugin didn't work for me. I have even a look at this solution but ...
0
votes
0answers
11 views

If i use a child theme to add new code blocks to header.php, how does it get inserted in the right place in parent's header.php?

I want to add <ul><li><a href="link">Link</a></li></ul> to my theme's header.php. This is new code that doesn't already exist anywhere. I have created a child theme....
0
votes
1answer
22 views

Having trouble with customizing blog posts on the home page

I can't seem to get this right. I am trying to load in the 6 most recent blog posts (2 rows, 3 columns, responsive). The post title would appear on top of the thumbnail image. Here is the design ...
0
votes
1answer
24 views

Setting custom canonical urls

I have a page that requests and displays information from a database. All is fine but I'm having some trouble setting custom canonical URLs for this single page only and its URLs (with parameters ...
0
votes
1answer
20 views

Open all external links in new window - need help with the code

I'm using this code to open all external links in new window (site is based on Wordpress): /* OPEN ALL OUTBOUND LINKS IN NEW TAB */ function autoblank($text) { $return = str_replace('href=', 'target="...
0
votes
0answers
15 views

Get directory of install in Wordpress

I want to get directory, where wordpress was installed from a scope of normal visitor. So when I have: /var/www/clients/client1/web8/web/tests/mywebsite/ I only want: /tests/mywebsite/ How can I ...
0
votes
1answer
28 views

Whitelisting items from custom options page

I'm a relative beginner, so anything that points me in the right direction is appreciated. I'm trying to whitelist options from the admin panel. I have an array in another file (item-whitelist.php) ...
0
votes
1answer
33 views

Buddypress update user avatar image via REST

I’m creating a custom back-end API to update a user avatar image via user id. So i send via post REST request this parameters: – user_id : The id of the user; – image: base64 image; – image_name: ...
0
votes
1answer
14 views

Parse error: syntax error, unexpected '}' [closed]

<?php if(empty($username)) {array_push($errors, "Username is required")}; ?> i put this line inside a php file but there is a problem with it, can someone explain what I'm doing wrong?
0
votes
1answer
41 views

Wp redirect - reset password

I'm stuck. I am doing a redirection from the approve post function to the link that establishes the password. This works, but it does not take the user. that is, open the page of reset password but I ...
0
votes
1answer
25 views

Help with preg_replace

I'm trying to remove 6 lines from my RSS feed using preg_replace. I've tested the regex online and it seems to select the lines properly. Somehow the lines are not getting deleted add_action('...
0
votes
0answers
19 views

wordpress returns http error 500 on a fresh install

I have centos7 machine running MariaDB and phpMyAdmin running properly. I set wordpress for testing running on this machine some months ago and everything was running fine, I finished my test and left ...
1
vote
1answer
11 views

Add_menu_page not displaying the menu in class based plugin

class Cosmo_Games { public function __construct() { add_action('admin_menu', array($this, 'create_plugin_settings_page')); } public function create_plugin_settings_page() { $...
0
votes
1answer
25 views

How to redirect (301) trashed post to it's parent taxonomy TERM ARCHIVE instead of 404 page

I have a taxonomy called "Sports", that includes terms: Football, Rugby, Tennis... What I want to achieve is when (for instance) a post that has the term football is trashed and a visitor try access ...
0
votes
1answer
15 views

add_filter function concatenate string and locate_template function

I am trying to inject a small php component to the end of my main site navigation. I have written this filter: add_filter('wp_nav_menu_items', 'add_css_switcher', 10, 2); function add_css_switcher(...
0
votes
0answers
47 views

How to Clear PWA cache when user Logs in or Logs out with SW

My site shows different content for logged in user and logged out user. The PWA troubles because the aggressive service worker cache shows logged out user content even after user logs in. Is there ...
0
votes
1answer
29 views

Error Uncaught ArgumentCountError i cant find it

I added more variables to the default function of wordpress and I see this error. Any suggestions? Thanks in advance!! add_action('new_to_pending', 'custom_wp_new_user_notification_email'); ...
0
votes
1answer
38 views

Get post content inside plugin class method

I'm writing a simple SEO class that will add the various metatag to the header of wordpress. I've two little problems with the wordpress api. The first is that I need to remove the last comma from ...
-2
votes
1answer
34 views

Detecting IP Address of someone using 'copy' function [closed]

Is it possible through WordPress (through a plugin, PHP or otherwise) to detect the IP of someone copying (ctrl+c) content on my website, and have that data sent/displayed to an admin? Appreciate ...
0
votes
0answers
6 views

Limit content size by character or word in database

I am not talking about the_excerpt() or the_content() output limit. I am talking about the actual content size limiting. I am using scraper to create posts from external source and link them with ...
1
vote
0answers
48 views

Repeating admin-ajax.php not found error in admin

I seem to be getting a repeating 404 error in the Chrome console when in wordpress admin very occasionally it gets marked as a 500 error for the same line, perhaps is something to do with an ...
0
votes
1answer
25 views

error_log is not working as expected in functions.php file

Error log on my index file get logged in the error_log.txt file but the same error log is not working in the functions.php file. I am using the latest WordPress and PHP 7.0. I am not using any plugin ...
0
votes
1answer
31 views

Search and Replace in database: How to replace data in SQL dump file on Windows?

Unlike with Joomla, one can't just search and replace a string in WordPress database because of serialized data. I am not sure what serialized data is, but it makes my life more complicated. Is there ...
1
vote
1answer
41 views

Fix 403 error on WordPress multisite network using subdomains

I've a WordPress installation that I've transformed into a multisite network. I'm using cPanel and I've followed all the instructions to configure the WordPress installation. I've set up the ...
0
votes
0answers
24 views

How do I get data from my database into my Custom Export Field

I am trying to get data from my database to export to a XML or CSV File by using a custom query. This is my function with the query : <?php function get_workhours($ID){ $sql = $wpdb->...
0
votes
0answers
18 views

String replace for Login/Logout concatenation problem in menu

I must be having another senior moment. The following code has been working fine for me for -years-. I applied it to a site using 4.9.2 with a child theme of Twenty Seventeen and it fails in a ...
0
votes
1answer
65 views

Personalize checkout text

I would like to hide some of the text in the checkout page: billing details, Order notes (optional) and product/total row in "your order" section. I am able to remove the input fields, but I cant ...
1
vote
0answers
20 views

Approve post and send the password

I am looking for a way to add my password reset function code the code what it does is that when the mail arrives to the user, click on Confirm and the post is published. (before it was pending) I ...
0
votes
1answer
154 views

Woocommerce textarea format ignored

I used the code posted by ClemC in Woocommerce add extra field to variation product with a textarea instead of a text_input. I succeeded to show my textarea under wooocommerce-default "variation ...
0
votes
1answer
29 views

Fix hover images blink

I have this css script generated using php, it's used to show a wordpress second featured image when an user hover. The problem is that the images are blinking and I don't know how to solve this small ...
0
votes
1answer
57 views

Where do I implement this display of User Meta Data, and how to put it in a table?

So I have the code below that should pull the user metadata of the currently logged-in user. <?php $current_user = wp_get_current_user(); echo 'Username: ' . $current_user->user_login . '<...