Stack Exchange Network

Stack Exchange network consists of 174 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]

The server-side programming language that the WordPress core, plugins and themes are written in.

0
votes
1answer
32 views

Help with find a bit of code to move from functions.php

I have been told that the code below contains malware and this is what the hosting guys sent me. But I do not know where this would be or what it means. I am a beginner so apologies if it sounds dumb. ...
0
votes
1answer
31 views

Co-Authors Plus: How do I get all authors with a query?

I've recently installed the Co-Authors Plus plugin and am trying to get all the authors from a post within a post loop. However for some reason when I use get_queried_object(), there is only one ...
0
votes
1answer
21 views

Count top level menu items

I need to get count of top level menu items. I have menu with 5 items and of of them has 1 submenu. This is current situation, but the user using the theme I am building may have some different ...
0
votes
0answers
11 views

Change button on product WooCommerce Subscription

I want to change the button on a product if a user is already subscribed to it. I display a list of products on a specific page. Each product as we all know has an "Add to cart" button. That "Add to ...
0
votes
1answer
24 views

3 different times on my Wordpress website

I have a wordpress website hosted at Hostgator (Brazil). The server shows the current correct time (in daylight saving time). In this example, the correct time is as below, ie 13h (America / São Paulo)...
0
votes
1answer
13 views

How do I output user_registered time in my correct timezone?

I am currently using Wordpress, and an element of user_registered returns the time of registration of the user. I have set the correct timezone, but don't know how to get the user_registered output to ...
0
votes
1answer
44 views

Shortcode not working - quotes seems strange

I have been through other posts and tried a lot. I have two wordpress sites on the same server and A runs fine with the plugin "PHP code snippets" but B just shows the shortcode [wbcr_php_snippet id=”...
0
votes
1answer
19 views

Send an email to specific adress when button is clicked?

I have created a custom page template with a search function, this search function shows posts, and I want to create a button on each post that when it is clicked will send an email to the author of ...
0
votes
0answers
23 views

Add class to body after page has loaded

I would like to add a Class called "snap" to the <body> tag only on two templates (the front page and on my single Custom Post Type page 'projects'). To do that I don't have any problem. But I ...
0
votes
0answers
7 views

Post template per category?

I have this single.php... <?php $post = $wp_query->post; if (in_category('portfolio')) { include(STYLESHEETPATH.'/single_portfolio.php'); } elseif (in_category('video')) { ...
0
votes
0answers
5 views

Display post from child category

I got a code here where it post all my custom categories then if you click a category if the category has child category it will display all the child and if there is no child category it will display ...
0
votes
0answers
15 views

WooCommerce Custom Pagination Layout

as currently my site product pagination is display as PREVPAGE 1 2 3 .. 15 NEXTPAGE May I know how I can make it as FIRSTPAGE PREVPAGE 12345 NEXTPAGE LASTPAGE ? I'm trying to achieve it same as https:...
0
votes
1answer
23 views

Template Loop - add switch case php

My plugin template is currently as follows: if ( $query->have_posts() ) { ?> <ul id="list-con"> <?php while ($query->have_posts()) { $query->the_post();...
0
votes
0answers
20 views

Add Row to Footer to display more widgets

I want to display the widgets I have created on function.php file in WordPress. This is my footer.php file code believe the problem is here </div> <!-- Page content::END --> <?php ...
1
vote
1answer
35 views

WordPress custom slug (endpoint) and compare all links

I work on the one i18n function. It will work with subdir. For example: eg.com/hello-world/en For this I'm support EP_ALL for the WP custom endpoints. function lang_add_endpoints(){ ...
0
votes
1answer
28 views

Add parent menu item in sub-menu in custom nav_walker

Currently I'm working on a project where we need to append the parent title as first item in the submenu for a mobile menu. What I try to achieve is this: <ul class="menu"> <li> ...
0
votes
0answers
9 views

How we can show HomePage ad to Category pages and Search Pages

I have Created a Plugin by getting code from How to put a banner ad between post 1 and post 2 on homepage only But this Plugin is working only on HomePage, But i want to show ads on Category (domain/...
0
votes
0answers
10 views

Add custom nav walker to UberMenu instead of wp_nav_menu

I am working on a website, that has a custom walker added to an existing nav menu. The code works great for a standard wp menu, but I cannot seem to add the same walker to an ubermenu (www.wpmegamenu....
0
votes
1answer
20 views

Background Music WP [closed]

this may be a stupid topic but a client has commissioned me this: some music to be included in some pages. I can not find any plugins to help me do this. Do you know anyone? Now, I was thinking if you ...
1
vote
0answers
22 views

Access Wordpress data from external PHP application.

I am a volunteer in a non-profit organization. I have taken over maintenance of a number of apps written in PHP/SQL/Dreamweaver. The apps are over 10 years old. I am migrating these apps from PHP/SQL ...
0
votes
0answers
30 views

Woocommerce showing only one product on main shop page of the exactly same tag

I have more than 3000 products on my website. I get all products from main dealer's database using XML importer. Anyway, i assigned same tag for the products of same type. For example, i have a oval ...
0
votes
2answers
52 views

AJAX pagination, update current page

I created a numeric pagination that loads the posts via AJAX. This is the PHP and jQuery code: // PHP Code function ajax_pagination_enqueue_scripts() { wp_enqueue_script( 'ajax-pagination', ...
0
votes
1answer
18 views

Remove Custom Divs from AMP pages

I am using Automattic's plugin to implement AMP on my website. Currently, to make my videos responsive, I wrap YouTube videos around a custom div. So, a YouTube video on my website looks like this:- &...
0
votes
0answers
51 views

Call jQuery function from PHP?

Right now I have code that looks like this: function search_ajax_fetch() { ?> <script type="text/javascript"> function searchFetch() { var keyword = $('#keyword').val(); if ( ...
0
votes
0answers
12 views

Show different forms depending on selected language

I'm using a theme that uses a booking form on the product page. It's an event booking theme. I wanted for the booking form to only show up on specific products. On all other products, I wanted a ...
0
votes
1answer
25 views

This occurs when I open admin or front on localhost

Recoverable fatal error: Object of class WP_Error could not be converted to string in H:\xampp\htdocs\edventus\wp-includes\default-constants.php on line 252
0
votes
0answers
38 views

Apply fix to a function

I need to apply this fix: protected function buildQuery($mode = 'POST') { … if ($mode == 'POST') { /* POST body has to be an array and NOT a queryString */ //$args['body'] = http_build_query($request)...
0
votes
1answer
24 views

Include style.css in the Child Theme with PHP

In https://codex.wordpress.org/Child_Themes is written that the best practice for including style.css in the Child Theme one must put the code below into the functions.php of your Child Theme but ...
0
votes
0answers
29 views

Input field duplicates on form submit by jQuery

I have a jQuery ajax function which adds some hidden fields to a form. I am trying to change the action of the form and then submit it using jQuery if ajax returns successfully. Here is the issue: ...
0
votes
1answer
14 views

Add 23 hours 59 minutes and 59 seconds to meta key before saving?

I have a plugin which has a datepicker in the post, and saves this date as unix epoch to visitor-date. Problem is that it always saves everything as the same time 00:00:00 and I want it to be saved as ...
0
votes
0answers
20 views

Country specific pages in a site

I’m working on an multi-national site for which the sponsors want pages supported so that each page: Can be served from a single default page regardless of the country (80% of pages), and Default ...
0
votes
1answer
13 views

Ajax search shows all results when user empties input?

Just managed to get ajax live search working, which means I can get the results instantly when I enter characters in the input. The problem appears when I clear the input, it will show all results. ...
0
votes
0answers
38 views

Show only lowest level category for all categories

I have posts on my wordpress that have many categories and then (usually) subcategories assigned. Right now, they're being displayed above each post excerpt like this: <?php the_category( '&#...
0
votes
1answer
32 views

PHP Strict Standards: Only variables should be assigned by reference

Here's the code in question. It started looking like this: $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id)); return count($comments_by_type['comment']); ...
0
votes
1answer
21 views

Return function results within shortcode

I'm trying to write reusable functions in a plugin and call the functions within a shortcode. But, I can't get any output. Why don't either of these methods work? <?php function say_sup(){...
1
vote
1answer
25 views

Only show search results with if current date is between two dates?

I have a custom post type which I can set a start and end date in the metadata. I use the function below to filter the search results and only show results from the post type visitor: function ...
0
votes
2answers
33 views

Changable favicon

I am looking for help to put single page favicon that would overwrite global one. Say for example I have wordpress website that is example.com and it has favicon set for every page. What I want is for ...
0
votes
1answer
27 views

Search only for posts with specific metadata?

I have a custom post type which creates events. These events have a start date and a end date. I want to be able to search for the events which occur on the specific day only. So if start date is 2018-...
0
votes
1answer
13 views

How to Get Linked Elements for a specific ml_source_elementid

I'm using MultiLingualPress* on one of my pages, which is multisite, multilingual. I am trying to get the permalink of a page based on two things: 1) The ml_source_elementid, which identifies the ...
0
votes
0answers
14 views

Search Plugin expects different date format in DB - workaround?

I have two plugins: Events Manager and Search & Filter First one stores dates as YYYY-MM-DD in database, second expects YYYYMMDD format. What would be an easy workaround to get this working? ...
0
votes
1answer
25 views

ACF background-color per post in a WordPress loop

I have the following loop in WordPress: <div class="container"> <?php $news = array( 'post_type' => 'post', 'category_name' => 'angebote', 'order' =...
0
votes
1answer
18 views

Reverse Cross-Sells (WooCommerce)

When you run get_post_meta( get_the_ID(), '_crosssell_ids',true); you get an array of all the products that the current product cross sells to. How do I reverse that? To get all the products that ...
0
votes
1answer
18 views

I need to edit a widget, with no dashboard access

What the title says. There's a widget on a website that I need to edit, but I only have ftp access. I've tried everything to try and locate where the template is for the specific widget I'm trying to ...
0
votes
1answer
14 views

How do I fix this error

I am having trouble with my website. I'm fairly new to wordpress so I could use any help I can get: PHP Notice: Undefined index: ics_add_slidelink_2_meta_box_nonce in /inc/slider/slider_post_type....
2
votes
0answers
117 views

WordPress “Link has expired” error on updating posts

I'm maintaining a WordPress site on GoDaddy for a client and they started to get the "this link has expired error" when they saved a post. It does not happen when I upload a file. However, I am ...
0
votes
0answers
9 views

WordPress AJAX not displaying content

I'm building a site within WordPress which will display two rows of images at the start, then on button click, two more, dynamically. I have four files involved in this process: case-study-card.php: ...
0
votes
1answer
31 views

WordPress produces identical hash all the time

So I was looking at WordPress'es source because I was curious how hashes are compared on the back-end. However, I am at a loss to understand how exactly phpass is meant to produce different hashes for ...
0
votes
0answers
18 views

Mobius theme, display header subtitle instead of excerpt in blog page

In the single post page, the post shows Title, Subtitle and content I'm trying to show only title and subtitle in the blog posts page instead of title and content Here is the functions.php code for ...
0
votes
1answer
27 views

Using custom fields for image alt and title

I've Add a custom field to my products editing page with ACF. Custom field name is my_seo_title ; Each product has a unique SEO Title. How can I use this field as an alt text and title for images in ...
1
vote
0answers
125 views

Basic Object Oriented plugin question

I'm looking to create a plugin that displays a custom posts label for posts that belong to selected categories. And since I'm new to OOP, I'm struggling to understand whether to use arrays instead of ...