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)

6
votes
3answers
305 views

Where do I put the code snippets I found here or somewhere else on the web?

Many posts here or somewhere else contain code, but they do not say where to put it. Example: I have found this post: How do I turn off 301 redirecting posts (not canonical)? I'm a newbie with PHP. ...
7
votes
4answers
4k views

What's the difference between home_url() and site_url()

My understanding is that site_url() returns the location where the wordpress core files are. So, if my blog is hosted at http://example.com/blog then site_url() returns http://example.com/blog But ...
0
votes
1answer
36 views

Remove “Published On” inside wp-admin

How do I remove this? Preferaly would like to do an action hook inside functions.php to remove this. I don't want the editor to see/edit when they published the article. Thank you for your help.
2
votes
1answer
131 views

Generate Advanced Custom Fields box in custom admin menu page

I have created an custom admin menu page called FCC Youtube with add_menu_page function which has some custom fields I manually generated via HTML and PHP: code ( just the part how I created this ...
0
votes
0answers
35 views

How to make this scroll script work on just one post

I currently have a jQuery scroller on a website I am developing so that when a visitor hovers over an arrow the content scrolls up and down. This is fine on single pages, but I now need to include ...
0
votes
0answers
29 views

Current path on page in functions.php

How can I get the current path of my page? I know how to do it inside a template file, but I need it inside functions.php. And it has to be before the send_headers hook, because I'll use this info to ...
-1
votes
1answer
31 views

Image width issue in IE [closed]

For some reason images are being displayed as a thin line in IE 8 and earlier and i cannot work out why this could be. I'm using CSS to re-size the images for the homepage, the reason for me using CSS ...
0
votes
0answers
31 views

Create custom permalinks / rewrite

How can create a custom permalink in my functions file that would include a template page when you go to a custom url: http://example.com/members/settings I have a template page at ...
0
votes
1answer
34 views

wordpress get_post_meta give only first value

I made one custome post in that there is one custom field call _as_roomname. I create total 5 custom post and I want to retrive all it's name but I get only first value. function postlogo(){ global ...
1
vote
1answer
63 views

Gravity Forms field entries into wp_query loop

I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)... add_action("gform_after_submission_18", "set_post_content", 10, ...
0
votes
2answers
63 views

Is it possible to disable a function of a parent theme?

I was wondering whether it is possible to completely disable a function that is called in a parent theme's functions.php and if so, how? (Of course without deleting the function. Rather by adding ...
1
vote
1answer
27 views

Remove class that has been added by parent theme

My parent theme generates the following class in body: style-cupcake. I don't want that. The best way to get rid of this is by adding my own functions in a functions.php file in my child theme, right? ...
0
votes
1answer
119 views

Post visibility option to theme front-end for author to select?

Is it possible to present author with an option to select visibility of a post (public, private, password) on theme front-end post adding without messing with Wordpress core? Any suggestions are ...
0
votes
0answers
32 views

Registration Fail Redirect Problem

We use two registration links allowing users to register for different roles: /wp-login.php?action=register&utype=subscriber /wp-login.php?action=register&utype=contributer The subscriber ...
0
votes
1answer
39 views

Why does modifying my functions.php file always result in a server error

Basically, every time I modify my functions.php file and reload it to the server my site "breaks" and nothing loads. As soon as I delete it, it starts working again. Now before anyone freaks out, I ...
1
vote
1answer
48 views

Setting Up Scheduled Tasks (For Scripts to Run)

I am going to make a script that requires a scheduled run time. What is the best way to do this in Wordpress? Or maybe this can be done through some PHP method? I'm having a hard time finding even a ...
3
votes
1answer
63 views

Different wp_mail_from and wp_mail_from_name for specific situations

I'm wondering how to create differents wp_mail_from and wp_mail_from_name for specific actions that use the built-in mail system in Wordpress. For example, when a new comment comes, notify the user ...
0
votes
2answers
49 views

Wp admin - Set default value to 999 in comments

When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can ONLY mark the 20 comments you see on current page. It dosent mark ...
0
votes
1answer
33 views

Archive.php, and post_is_in_descendant_category

I've got a small issue with my archive.php. I was trying to set up an If statement that displays a certain category and sub categories with a different layout & sidebar based on my theme options. ...
2
votes
3answers
778 views

Logout redirect to current page - function

I'm looking for a function that can redirect users when they logout to the current page. I'm looking for a code I can use in functions.php?
0
votes
2answers
61 views

Adding code to the function file

I would like to move my large php functions out of the index or template files and into the function.php file. Would it be something like this? function grab_code(???) { ??? .= '<div>some ...
0
votes
1answer
162 views

Single dash converted to double dash

As the title says, if a single dash is used with a space between each side eg. 'Die Hard - Action Film' is written in to a WordPress post, once published it comes out as 'Die Hard -- Action Film'. If ...
1
vote
1answer
22 views

comments_number display outside specified span

I want to display the number of comments a particular post has, so i thought i'd use comments_number, however when i use this the comment number gets printed outside of the span it's supposed to be ...
0
votes
1answer
99 views

List direct children of page

I am currently using the following function to list the children of a page, however the function recursively finds children of the children and I only want to list the direct children of ...
0
votes
1answer
42 views

Conditional Content Display

I"m trying to replace the string "Something Nice will show up here" in the block of codes below with WordPress loop but it doesn't seem to be working. I'd like when Link1 is clicked on, let the post ...
1
vote
1answer
23 views

problem with has_post_thumpnail in foreach loop

I have a code that display the post if has_post_thumpnail the problem is it shows all the posts wheather it has thumpnail or not <?php global $post; $args = array( 'numberposts' => 5 ); ...
4
votes
1answer
76 views

function_exists call in function.php

In the function.php file of the twentyeleven the setup function checks to see whether it exists before running it: if (!function_exists('twentyelevent_setup')): function twentyelevent_setup() { ... ...
0
votes
0answers
19 views

PHP Parse error - wordpress [closed]

can anyone please assist me? I have this error on my website (wordpress) when trying to load it. I was in functions php doing some coding. Then I deleted the coding I placed in there, but the error ...
0
votes
1answer
121 views

WooCommerce Tabs

In my theme, I have the WooCommerce plugin installed and would like to rename the "Catalog" tab, located under the WooCommerce > Settings submenu page. Am I able to do this from my functions.php ...
1
vote
2answers
46 views

Image rotation fails to regenerate custom sized thumbnail

I'm using custom image dimensions in functions.php like this: add_image_size( 'custom-size-thumbnail', 120, 120, true ); I uploaded some pictures with wrong orientation, so I used "edit" options to ...
2
votes
3answers
595 views

How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?

The current result is "PHP Fatal error: Call to undefined function wp_get_current_user()" which makes sense, but doesn't help. I need to use $current_user. Here is the code I'm currently using: ...
0
votes
1answer
94 views

Storing password (functions.php)

I have created password form where visitors can access any password protected post with belonging password. Basically you enter unique password and you are redirected to a post which is protected with ...
0
votes
1answer
43 views

Perform function on publish AND save (not just save)

I am using this function to auto-set a post title based on a couple of custom fields: function set_event_title( $data , $postarr ) { if($data['post_type'] == 'event') { $getdate = ...
1
vote
2answers
52 views

Dynamically add id to heading tags

How do I add an id attribute dynamically to every heading tag on a wordpress website using php? I wanted to make it so that for every heading tag (h1, h2, h3, h4, h5, h6) I have a unique id attached ...
0
votes
1answer
42 views

Saving multiple Metabox contents

I'm putting together a fairly simple Custom Page for a friend on their WordPress site, but I'm having some real difficulties getting the contents of the Metaboxes to save correctly. WordPress doesn't ...
0
votes
1answer
35 views

Defining multiple categories for showing latest posts

I have a function that lets me display the latest posts on my website, however i want to function to show posts of multiple categories at not just one specific category. Check the code below and what ...
0
votes
1answer
77 views

add sidebar area to header of child theme

How can I add some extra sidebar locations for widgets in a child theme. The difficulty I'm having is because the parent theme uses some pretty gnarly setup to define the current sidebars. I would ...
1
vote
2answers
33 views

2 Loops, Only Displaying 1 Loop in Both Loops

I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either Movie Trailer or ...
2
votes
0answers
27 views

Modifying Footnote Plugin for Descriptive Title Attributes

I've been struggling for a couple hours now to get this working... Hopefully someone here can help me. I just started using the wp-footnotes plugin, and I'm trying to set the title attribute on ...
0
votes
0answers
25 views

previous_post_link() : Within all categories except one

According to this tutorial if I want to display link to previous post in the same category, I can use the following code: <?php previous_post_link('%link', 'Previous in category', TRUE, '13'); ...
2
votes
2answers
58 views

Auto close (hide) custom metabox / set default state

I am using the WordPress function add_meta_box() to add my own custom metabox. So how can I auto close/hide on page open ? Currently, I just add a CSS class closed to metabox's <div> element ...
0
votes
0answers
37 views

Customize wp-caption output

I'd like to customize the output for the wp-caption shortcode. I need to put the attachment full-size URL wp_get_attachment_image_src($post->ID, 'full') function custom_img_caption_shortcode( $a , ...
-1
votes
1answer
33 views

Integrating CSS Into a WP Function Call [closed]

Below is a code I use to display post views. It is integrated with an options panel which allows users to choose whether to display it. I would like to integrate the div class .postviews directly ...
0
votes
0answers
34 views

Wordpress redirect after update profile not saving?

Im using the following code to redirect a user after they update their profile but its not saving any changes that are made (including custom user meta fields).. Any clues? Thanks! add_action( ...
2
votes
5answers
1k views

Show Video in Excerpt

So I recently figured out how to change my blog page to display excerpts by changing the <?php the_content(); ?> to <?php the_excerpt(); ?> in my index.php file. I am using a custom child ...
0
votes
1answer
45 views

Countdown to date function?

When a user signs up on my site they have to select a date as part of resignation. On their profile page I need to show a countdown to that date. Something simple like attached. How can I create this ...
0
votes
0answers
26 views

Figure element with multiple image short code

I have a short code I developed that goes like this: [figure description=""] [image src="" title=""][/image] [image src="" title=""][/image] [image src="" title=""][/image] [/figure] What it does ...
0
votes
0answers
31 views

Updating user_meta from pop-up form in back-end

I have created a custom wordpress backend area, which lists out all members on my wordpress site. Currently, there is a point system involved for loyalty rewards, which is maintained in this back-end ...
0
votes
1answer
356 views

Change ul class=“children” for wp_list_pages?

Hello I'm using this code to print a list of Pages and Subpages: <ul> <?php wp_list_pages('title_li=&depth=2&child_of='); ?> </ul> It outputs: <ul> ...
1
vote
1answer
65 views

When tax_query used, results disappear (0 =1 produced)

I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post_type, and displays results accordingly — A user makes a selection from 3 drop-downs on a form, each have a ...

1 2 3 4 5 25