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 [functions]

A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

0
votes
1answer
531 views

Code to insert code into single php

I'm using a plugin that puts stuff on my single.php page. I can turn off this stuff by inserting <!--code--> in the text side of the editor for any single post. I want to do <!--code--> ...
0
votes
0answers
8 views

Add Product Permalink Before Order Item Meta

I am using the following code to add product permalink in woocommerce admin order page- function fpd_custom_order_item_values($_product) { $url = $_product->get_permalink(); echo '<p&...
0
votes
0answers
18 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
0
votes
1answer
604 views

Set display name from nickname with register process

It is possible set display name from entered string into nickname registration field? I trying do this with simple hook, but after all it is not work. function set_default_display_name( $user_id ) { ...
0
votes
1answer
15 views

Add Product Permalink in woocommerce admin order page

I am trying to add the permalink of product on woocommerce admin order page with this code: function fpd_custom_order_item_values($_product) { $url = $_product->permalink; echo '<p>'.$url....
0
votes
1answer
32 views

Remove pagination if search returns empty

I made a fix that when the searchbar is empty, it returns 'No results', instead of all posts, but the pagination still shows up. Does anyone know a fix for that? My code search.php: <div class="...
0
votes
1answer
19 views

Shortcode to insert default text and change one word throughout it?

A beginner developer here, working on my first project. I've been trying to find some guidance on how to create a plugin or function to create a specific shortcode. Let's say I have two default ...
0
votes
2answers
542 views

Can I use a function to return HTML and the result of another function?

I have a very simple function to create a shortcode to get the name of my page. I was using this shortcode in a form, but WordPress changed the Shortcode API and that no longer works. So I was ...
0
votes
1answer
24 views

I'm creating a online store for my website, my aim is to add description to products in home page only how can i achieve it?

Here is my code i need to add description to homepage only add_action('woocommerce_after_shop_loop_item_title', 'description_in_shop_loop_item', 3 ); function description_in_shop_loop_item() { ...
3
votes
4answers
14k views

What is this code in my theme's functions.php? if (isset($_REQUEST['action']) && isset($_REQUEST['password'])

This code appears in my theme's functions.php, also in child theme's. I've deleted it for two times but it comes back. What is it? if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['...
0
votes
1answer
12 views

how to increase connection time

actually I'm using this script To increase the connection time // Reste connecté à WordPress durant 1 an add_filter( 'auth_cookie_expiration', 'keep_me_logged_in' ); function keep_me_logged_in( $...
7
votes
2answers
211 views

Use author author display name in permalink structure for pages and posts

I need to add the author name as a subdirectory prefix for all user's posts and pages. For example: example.com/johndoe/ //The author page for John Doe example.com/johndoe/category/test-post/ //Test ...
0
votes
1answer
552 views

Populate custom post type/custom fields from an external database

I have a custom MySQL DB(same host/different domain) with a lot of vehicle information. What we want to do is populate a custom post type and custom fields with this data so that it's SEO friendly in ...
0
votes
1answer
593 views

I changed Functions.php and now I get “cannot decode raw data NSURLErrorDomain:-1015” (not blank)

I'm desperated... I added some code to the file functions.php (from wp-includes in Filezilla), and now I get "cannot decode raw data NSURLErrorDomain:-1015" in Safari; "Es posible que la página web ...
0
votes
1answer
26 views

Best way to use a large array in function

I need to define an array which has more than 15000 values in the wordpress functions file: $validpin = array(110019,111222,112233); I have written only 3 values to explain but the actual array ...
0
votes
1answer
21 views

Writing a function to detect an event

I'm using The Events Calendar to handle events on a site I'm building. I'd like an include to fire if the user is on an events page (archives, single etc etc). My include has a handful of custom ...
0
votes
0answers
13 views

get_locale() is different from $locale

for a language switcher I need to change the get_locale value to the needed language which works great using this code in my functions.php add_filter( 'locale', 'set_my_locale' ); function ...
-1
votes
0answers
27 views

how to match preg_match 2 word are same page we want second word not 1

let see my source code <?php class MEmbed_xvideos { public $url; public $user_id; public $category; public $status; public $video; public $errors = array(); public $...
2
votes
3answers
14k views

ajax live search for post title

i m creating a AJAX live search to filter posts title in my wordpress theme. As i write something in input it show all the post in result, Not filtering it to get custom post.. How to search live ...
0
votes
0answers
24 views

Assign user capabilities to a Custom User Role not working

I have a New User role called client admin. This role must create, list, edit, delete, remove user for the site. I add the following code the Site. add_role( 'client_admin', __( 'Client ...
0
votes
1answer
535 views

How to fix blank pagination links?

I am working on a Wordpress blog that has what appears to be custom pagination for the posts. As you can see here the correct amount of links are being rendered at the bottom of the page, however ...
0
votes
1answer
48 views

Cannot fetch posts with certain 'product_cat'. WP_Query is empty

I want to set attributes for woocommerce products in certain product category. The query, however, doesn't seem to work. I've placed the following code into functions.php of my child-theme. Tried ...
-1
votes
0answers
11 views

Replace a part of code woocommerce

I changed a part of code of Woocommerce (/wp-content/plugins/woocommerce/templates/single-product) and I would have liked to know how to save and declare it in my theme, to avoid leaving my modified ...
0
votes
1answer
531 views

can't see categories in appearance-menu-categories

I have a php script that takes categories from softonic.com. It is supposed to insert these categories inside an apps category. It does it with wordpress functions. After launch my script I can see ...
0
votes
1answer
3k views

How to add widget in main menu

I want to display widgets in main menu. There are few plugins to do this and i already used in my previous projects. But now i want do without any plugin. I can create a custom sidebar and call this ...
1
vote
1answer
21 views

What does the author_nicename parameter do in get_author_posts_url()?

I was looking at get_author_posts_url() which takes the user id as a param and returns a URL. It has an optional second parameter $author_nicename. get_author_posts_url( $author_id, $author_nicename )...
1
vote
1answer
26 views

get current product name in functions.php

i create a button in a current product page after woocommerce_single_product_summary i would to get information about the current product ( for example name and price) and through the button send an ...
1
vote
2answers
201 views

Refactor create_function

I'm getting several create_function is depreciated errors from a plugin as the result of a recent WP upgrade to 5.2. The plugin is no longer supported which means I need to refactor the code myself. ...
3
votes
1answer
132 views

Function to Download External Images to My Site

I display images on my site from other sites. The URL is saved in a custom field named couv. I would like to download these pictures on to my site and create a new custom field with the new value ...
0
votes
1answer
600 views

Simple JS function Not Working

I have been trying to get a simple JS function to work for the longest while but its just not working. Console says "test is not a function. echo '<input type="hidden" value="'.$return_survey_url.'...
0
votes
2answers
14 views

Will has_category be true is used on index and one of queried posts has the category?

If i use has_category('dogs') on a template like index.php or archive.php or search.php and one of the posts displayed on the loop have the category dogs, will the function return true? I know it ...
0
votes
1answer
25 views

Reload page with a different shortcode when a user selects from a dropdown

I'm using WP Job Manager, and the page which lists all available jobs is delivered using a shortcode which can be customized. so [jobs per_page="10"] is outputed in the frontend as: <div class="...
0
votes
1answer
50 views

Load custom post type with ID in a shortcode

I developed a theme for the first time. I created a custom post type for banners/call to actions that I want to include in different posts with a shortcode. The shortcode should look like: [banner id=...
-1
votes
0answers
14 views

How to find which theme and plugins a website uses with PHP? [closed]

I want to create my own theme and plugin finder like whatwpthemeisthat.com & wpthemedetector.com & isitwp.com. I want to use Wordpress and PHP for this. Can you give me an idea of what I need ...
0
votes
0answers
6 views

How to change post_author when making a user as admin programmatically

When making a new USER in the backend singed in as admin, wp_posts signed assigns the post_author of that of admin, I need it to be changed so I can have search results reflect that of the actual user....
0
votes
1answer
49 views

How do you completely remove the default header and footer using functions.php?

I cannot believe that this question has not already been answered, but the search does not come up with anything. If it has already been answered, please point me in the right direction! There are ...
-1
votes
1answer
22 views

wp_get_current_user->user login returns %20 for spaces

I’m creating a custom form in CF7 and want to autocreate a link in the table to the users id via a shortcode plugin that does the business in CF7. It works fine when the user login has only one word. ...
0
votes
1answer
16 views

Plugin Generate Unexpected output during activation

When i'm going to active my plugin that i create for sample , wordpress got me 1 unexpected output during activation ! This plugin actually has nothing but a Shortcode that will echo Hello ! I ...
1
vote
1answer
19 views

How do I create a new WP admin color scheme?

I followed this guide, but idk if it doesnt work for WP 5.0+ or if im doing something wrong. I added this to my functions.php and the css file is a copy of the Light Scheme. function ...
0
votes
0answers
26 views

Remove <figure> HTML tags from all posts

How can I remove tags from all posts on WordPress? I want to remove that tag from my WP feed: mkt-d.hospedagemdesites.ws/wp/feed. I'm using that feed to output posts in an external blog and the ...
0
votes
1answer
28 views

Remove <figure> tag on my RSS Feed

I need to remove the tag that appears on my feed content ($content variable). http://mkt-d.hospedagemdesites.ws/wp/feed/ Is there an existing function to this task? Some tags appear with width ...
0
votes
1answer
665 views

Allow user to select location and then set cookie for location in WordPress

I am needing to allow a user to select a location from a dropdown on the front-end, that then sets a session cookie for that chosen location... any help here? Ok so this is the outlined task: ...
1
vote
1answer
27 views

How do I redirect all 404 error url to Subcategory url

I have a b blog of over 200k+ post and I moved all post from a specific category to a subcategory, I have also deleted the post from the my main site, so all the post of that category have been moved ...
0
votes
1answer
827 views

Remove External Links from WordPress posts Using add_filter() in Theme functions.php

We have been searching high an low for a plugin, code sample or example of how to remove all external links at the theme filter level but can't seem to find anything online. We want to keep the ...
0
votes
1answer
37 views

AJAX button run function

I want after click button run function, . All is in one class. JQUERY jQuery('#text2').click(function() { var data = { 'action': 'myfunction', 'whatever': $button.data('text2'), ...
0
votes
1answer
20 views

Adding Custom Body Class for Page: Shop

been hacking at this for some time and haven't been able to make much progress. The goal is to add a custom body class to a specific page. -I know there are a few answered posts on this topic, and ...
0
votes
0answers
27 views

Modify post image in full size

I have a website where the client attached many “full size” images to posts, most of them in 5000px width, is it possible to run something for resizing those images to large? Instead of going through ...
0
votes
1answer
302 views

Load admin bar without wp_head or wp_footer [duplicate]

Is there any possible way to load admin bar without wp_head or wp_footer? If no, so maybe there is a way to load wp_head() or wp_footer() to catch only admin bar functions, styles and scripts? Is this ...
0
votes
1answer
643 views

Modify function Shortcode_atts

function get_date_posts($params, $content){ $default_params = array( 'post_type' => 'post', 'order' => 'asc', 'orderby' => '...
0
votes
0answers
33 views

If click on Save/Publish change Post Status to Pending Review instead Publish

Here's my problem. I need following solution. If a user is in the admin area of Wordpress and is not an administrator - and creates a page or product(via WooCommerce) - that if this user clicks on ...