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.

learn more… | top users | synonyms (2)

1
vote
1answer
916 views

Using PHP to toggle stylesheet and header image, set in cookie

I haven't done a lot of work with cookies or Wordpress before so I think I've been a bit over-optimistic in my quest :p I have created two themes for my site, night and day. I would like the user to ...
0
votes
1answer
111 views

Conditional required fields for Wordpress Contact Form 7

I know this might be considered off topic but I am not sure where else to post this as it also pertains to WordPress as well as the plugin Contact Form 7. If you know where I should post this other ...
1
vote
2answers
290 views

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (alerts.js) located in ...
0
votes
0answers
21 views

Automatic Logout on from another active session

I have a made application over Wordpress for premium user where user can see page after logging into his account. but there is issue that same user can login form multiple computer, so I want to make ...
3
votes
1answer
2k views

Is it possible to use a forgot password url filter?

i recently found that a login url filter is available but i can't find a solution for the forgot password as well, for the login url i use this: function custom_login_url($login_url) { return ...
0
votes
0answers
44 views

echo value from 'select' field type into page template using cmb2?

I'm using CMB2 plugin to add metaboxes into a custom post type. I'm adding the additional metaboxes via functions.php onto child theme. It may worth to mention that parent theme/custom post already ...
0
votes
0answers
118 views

Get First Image Or youtube Thumbnail with link to youtube video

Looking for a single function to grab the first image or video thumnail (with link to the video location i.e. youtube) Havent quite found one that will work. My youtube file starts with there new ...
0
votes
3answers
4k views

redirect wp-login.php to another page

I would like to redirect this page wp-login.php to /login page. So when a user clicks on a link like this <a href="/wp-login.php">login</a>, wordpress will redirect him to /register . I ...
0
votes
0answers
20 views

wordpress not calling peliegro functions.php?

I'm very confused with this question because I'm not really sure what is happenning, but as far as I know, my "father" functions.php is not being called. I'm using peliegro and peliegro Child. What I ...
2
votes
2answers
5k views

Ajax call always returns 0

I have a problem with AJAX returning 0 always! I have done everything by the book and can't figure out what is wrong? Please help!! Here is my Ajax call: //Pass data through AJAX var ...
2
votes
2answers
80 views

How to show in search results posts with a particular tag in a particular category?

As the home page of my blog I've a static page. There I want to show the navigation of the site. Category1 Sub-Category1 tag1, tag2, tag3 Category1 Sub-Category2 tag1, tag2, tag3 ...
0
votes
0answers
12 views

Php function modifying the page's rendering engine buffer and blocking caching plugin

I tried to create a plugin which creates pages based on a CSV or excel file containing hundreds of city names and postal codes. It creates one page per city, with always the same design but different ...
1
vote
2answers
34 views

WP Query. Is there a maximum size?

I develop a plugin that searches for a duplicates of WooCommerce products in a very specific way. It works great in our test environment, but on the client's original setup it does not execute. It ...
1
vote
2answers
823 views

Defer all js except certain ones in functions.php file

I read How to add defer="defer" tag in plugin javascripts? and the code @toscho posted works good to defer certain js files or deferring ALL js files by commenting out the contact-form-7 ...
0
votes
1answer
36 views

Use WP_Query Data In Cookie

I've collected an array and set-up a cookie via functions.php, both work fine. However, I really need to post the data to the function and set the cookie as this information will vary per customer. ...
0
votes
1answer
29 views

two search forms on the same page

I have a mobile and a large screen search field. I am trying to load these both on the same page. I am using JointsWP Starter theme. Here are the functions: function joints_wpsearch($form) { $form ...
2
votes
3answers
374 views

How to display post tags

I'm converting an HTML template into a wordpress theme and I'm having some trouble displaying the post tags within the functions.php file. What I would like to do is add the following code into the ...
4
votes
1answer
83 views

How to not allow users to create new tags, but allow to them to use existing ones

I want a certain role to be able to add new tags, but other users should just be able to use the text bar to search for existing tags. I know I can hide the tag bar in the sidebar, but I don't want ...
0
votes
1answer
652 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
0
votes
0answers
12 views

is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript

Is there a predefined JavaScript function that can be use to check whether the site is being previewed in the Customizer which returns true if it is or false if it's not, just like what ...
0
votes
0answers
22 views

Formatting post content to exclude gallery

I have this code which takes the first gallery for a post's content, and formats it with more code preparing it for slideshow usage with css and js. $gallery = get_post_gallery_images( $post ); ...
1
vote
2answers
659 views

Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn't solve so far. I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define('WP_USE_THEMES', false); ...
0
votes
1answer
379 views

How to add nav menu items to a specific position within a menu

I'm adding login/logout links to a nav menu using the following code: function rp_add_login_logout_links( $items, $args ) { $link = wp_loginout( get_permalink( get_option( ...
0
votes
1answer
22 views

how to create table during plugin installation in side a class

I am creating oop base plugin. So how to create table during plugin installation in side a class.But I could not create table. This is my approach.What wrong with me. class Notification { ...
0
votes
0answers
23 views

does it need any special functions to write in function.php?

does it need any special functions to write in function.php of template for single-{post_type}.php? I created a custom theme , but it does not move the single-{post_type.php}, my page is ...
3
votes
4answers
6k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...
0
votes
1answer
421 views

Change custom post type slug from plugin options

I'd like to give users the option to change a custom post type slug in my plugin. Using this answer, I'm able to hardcode it into a function: Redeclare/Change Slug of a Plugin's Custom Post Type ...
0
votes
1answer
49 views

Excerpt for pages not showing

I am creating a simple wordpress theme and need excerpts for pages. I have tried the code from many topics some resolved on 'wordpress SO' but nothing works. Because I created the theme from scratch ...
0
votes
0answers
12 views

Changing a button label of WP_Customize_Image_Control() doesn't take effect

I tried to modify the Customize Image Control class and replace the instance of 'default' => __( 'Default' ) with 'default' => __( 'NEW LABEL' ) and re-classname it like this: class ...
0
votes
2answers
26 views

How to store / access files in child theme folder

We are moving a HTML/PHP site to WordPress and want to use as much of the current code as possible. We are using the Avada theme, and have created an Avada child theme folder with the 2 required files ...
0
votes
1answer
1k views

How to access global variable $menu inside a class function

am puzzling why can't i access the global variable $menu inside a php class function class adminMenus { public function getWPdefaultmenus(){ global $menu; return $menu; } } using ...
0
votes
1answer
498 views

get_post_meta not working inside a function in functions.php but works outside

function notify_new_posts($post_id) { $keyval = get_post_meta( $post_id); $buyer_wdistance = get_post_meta( $post_id, 'cf_wdrive'); //$buyer_wdistance = $keyval['cf_wdrive'][0]; ...
0
votes
1answer
51 views

How can I include user meta information in the resulting array of a WP_User_Query?

I'm trying to accomplish some fairly complex custom functionality on a custom WordPress site. The client has an 'About Us' page that includes a list of all team members and their pictures. We're ...
2
votes
3answers
3k views

Load post with a different template?

Let's say I have a single.php file with a certain layout (graphic intensive). I want to create a sort of plain-text version of the same page that is only called when the user clicks the provided ...
0
votes
1answer
650 views

Creating wordpress user registration form

I am having a form page called Test Form with this form : <div id="container"> <form action="wp-content/themes/max-magazine/TestForm.php" method="post" name="myForm"> User <input ...
0
votes
3answers
154 views

Show media-uploads to all users

I want my media-library and all currently uploaded files distributed and available to all users. I am using the User Role Editor Plugin Is there any functions.php hack that makes all media-uploads ...
0
votes
1answer
26 views

How to override this theme function in child theme

I'm working in a child theme and I need to override a function in order to remove some unwanted items on a top menu. So I have research a bit and found a lot of docs, really, like this, this and this ...
0
votes
1answer
30 views

How to set up an auto delete post?

I want to create a form in which when a front-end sets a date and on that date the post gets automatically deleted. Is it possible?
0
votes
1answer
23 views

Custom posts - tag pagination

I'm using the following code to output the custom posts that belongs to a tag: add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag() ...
0
votes
2answers
484 views

AJAX values converted to PHP Variables?

I just started playing with Wordpress and I have a question about the AJAX side of things. I think that I understand how the AJAX front-end to server side processing, back to font-end works. But, I ...
0
votes
2answers
488 views

Custom registration form in shortcode getting internal server error 500

I created a custom registration form which works fine when used as a custom page template. I needed it as a shortcode so I created a shortcode using the function below /* Custom shortcode */ function ...
0
votes
1answer
421 views

function triggered by “manage_users_custom_column” filter not working

I am trying to add a custom column un users.php but it stays empty. I have successfully added a column to the users admin page with this code in my theme's functions.php file: function ...
1
vote
2answers
350 views

Custom gallery in wp3.5

I used a tutorial I found for a slick little custom gallery in 3.4, but upon upgrade to 3.5 it no longer works. I'm trying to learn php still and can't seem to get this working again, as I either get ...
2
votes
1answer
6k views

Using wp_get_nav_menu_items() to list children of children pages

I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do ...
1
vote
1answer
75 views

Issue adding text after short description on product pages Woocommerce [closed]

I am trying to add some text after the short description on woocommerce. I have come up with the following add action but when I use it, it replaces the existing short description text. Is there a ...
0
votes
0answers
16 views

Query custom post in tag archive

I created a custom post and added the standard Wordpress tag functionality: function btp_work_register_post_type() { $args = array( 'label' => __('Works', 'btp_theme'),'labels' ...
0
votes
1answer
32 views

Getting out side of wp root folder from function.php using absolute path

Hi Everyone I am having a relative path issue with linking a css file using a absolute path. Basically I am having the exact same problem as the person here however I do not want to use the URL of ...
1
vote
1answer
894 views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
1
vote
2answers
590 views

Update user meta of author when post content is viewed

I have a value that I'm trying to store as user meta for authors on my site. I need it to update itself every time the content of a post is viewed for that author. Here's as far as I've gotten but it ...
5
votes
3answers
3k views

How to customize the_archive_title()?

In my child theme's archive.php, I have the following code for displaying the title of my archive pages: <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ...