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)

2
votes
2answers
255 views

Clean-up script tags

I want to clean up <script> tags generated by WordPress to produce more semantic output for HTML5. You can already do this for <style> tags using this code attached to the ...
0
votes
0answers
44 views

New WP_Query calls Pre_get_posts filter twice

On my WP theme template page, I am running a new WP_Query. It seems to be calling my pre_get_posts filter twice, which then wrecks my custom parameters. The second time the pre_get_posts filter is ...
1
vote
2answers
612 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
0answers
15 views

WordPress permanently logging users out

I am using WordPress as a solution for digital signage on large displays and on personal computers in a company. In this use case the WordPress installation is a closed system which needs a login to ...
0
votes
2answers
23 views

How to add the post ID (or any other post data) to a Contact Form 7 mail?

I've downloaded Contact Form 7 to add contact forms adding a simple snippet after every post, and I've added it in functions.php like this : //if post type I add a form function is_post_type($type) ...
0
votes
1answer
38 views

Function to replace comment's accented characters before posting

I have some weird problems with encoding my Wordpress website and I can't add comments with accent words. when i try to do it, i received error by WP. What i need is just a function that read the ...
0
votes
1answer
40 views

What add_action reference should I be using or should I use do_action?

I am working on some automated emails. I am fairly new to add_action and do_action. I am having a tough time understanding it. The site in question has number goals set up that people reach over ...
0
votes
3answers
60 views

Include Jquery libraries in wordpress theme?

I have a file in my theme's JS folder named cycle2.js. How do I include the Jquery from 'wordpress→includes' into my theme? How do I load this custom JavaScript file 'cycle2.js' into my theme? I ...
1
vote
2answers
96 views

Custom post status not working

I'm trying to create two custom post status'. I used the Codex to generate the code and that didn't work. Then I went to http://generatewp.com/post-status and it didn't work either. It isn't showing ...
0
votes
1answer
30 views

Change meta tags programatically

Is there a way to change the meta tags not in the head but in a template file through code? I would like to change the meta tags <meta property="og:title" content="title" /> <meta ...
0
votes
1answer
22 views

Code to display category-specific single.php is overriding normal single.php, too

I have two different post type categories on the site I'm building at the moment - "press" and "blog". I used the following code, inserted in my child theme's functions.php file, to get the "press" ...
0
votes
0answers
18 views

Disable iframe in wordpress catch_that_image

I want to ask how to fix catch_that_image in wordpress ? I'm using code in wp-content/themes/name/functions.php function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ...
0
votes
0answers
21 views

Using Xeditable with Bootstrap my post.php function says 404 Notfound but executes the db update?

I am using the Xeditable library with Bootstrap 3. I have everything setup to work... and technically it is working.. except that when I submit the value via the popover the network response is a 404 ...
0
votes
1answer
17 views

WordPress styling recent post

Trying to replicate the theme shown here http://i.imgur.com/k60YtiX.png. As you can see on the screenshot the first post is black and the second post is a grey colour. My progress so far is just at ...
0
votes
1answer
21 views

WordPress rating by views [closed]

I am trying to create a system much like the one on this website. http://i.imgur.com/0trw2c3.png What happens is, if the post has over 1,000 views it gives it a nice little icon above the featured ...
0
votes
1answer
28 views

Registration form not registering First and Last name

I'm creating a custom registration form which works using username and email inputs, but when I include First and Last name fields it won't let me register. Here is the form: <form ...
0
votes
1answer
21 views

Custom Behavior when Adding New Custom Post Type in Dashboard

I have a Custom Post Type that I'm doing some custom work for. I want to attach some custom functionality to the post type once it's created but an admin can only trigger the custom action from the ...
0
votes
1answer
25 views

WP_Query function for custom post type

I've got a CPT for random homepage banner images (so we can test different images and call to action language). I've got a custom field for the post type that accepts a specific ID for each banner so ...
1
vote
1answer
28 views

Add before_content and after_content to register_sidebar

Is there any way to add two new functions, before_content and after_content to the register_sidebar function? These would work like before_title and after_title, except it would wrap everything that ...
0
votes
1answer
19 views

Where do I store custom functions that call custom page template files?

I've created a Wordpress Page template called head.php I then went into /wp-includes/general-template.php and by replicating the default get_header() function that is already there I added this new ...
0
votes
1answer
25 views

Showing user profile data on front-end

I'm making a profile-page so my members can update they're details trough the front-end. The problem is that the select-box named "Province" won't show the correct data when the page loads. How can i ...
0
votes
1answer
24 views

wp_nav_menu work in functions.php but not in the theme

I use wp_nav_menu with this code in functions.php: register_nav_menus( array( 'sidebar_menu' => 'Sidebar menu', 'topmenu' => 'topmenu', ) ); $args = array( 'theme_location' => ...
0
votes
0answers
19 views

Can a single.php file be coded to allow HTML download from a button?

I have been searching on WP and on SO for a way to code a custom-single.php to allow the HTML code in that document to be downloaded from a button on the rendered site. What I have done is created ...
0
votes
1answer
18 views

Removing get_template_part in child theme

Parent Theme loads some template files in its functions.php as follows: get_template_part ('lib/login/register.php'); I want to remove this file in child theme and include my custom php templates. ...
0
votes
1answer
30 views

Exclude Custom Post Type & Pages From Auto-Tag Function

I am happily using this bit of code to auto-tag posts by author (thank you again cybmeta): add_action( 'save_post', 'add_authors_name'); function add_authors_name( $post_id ) { $post = get_post( ...
0
votes
0answers
7 views

Why does wp_insert_post take longer than media_handle_upload?

I've got a page on my Wordpress site where users can submit posts or documents through the front end. I use wp_insert_post for the posts, and media_handle_upload for documents. wp_insert_post takes ...
0
votes
1answer
51 views

If WooCommerce Stock Updates, Also Update Specified Field Values

I would like to have a function that should update the Est. Dispatch Date Field ) in whenever WooCommerce Stock Value / Stock Amount changes even when order is placed and stock amount is reduced by ...
0
votes
0answers
25 views

site_url() returns with additional backslashes

I am using site_url() function and it returns the address as http:\/\/vip.local\/cc where I can see that WP automatically adds unnecessary backslashes. Is this for some escaping purpose? I tried using ...
0
votes
0answers
16 views

How can I detect if user has subscribed Memberpress product already

How can I detect if user has already bought a memberpress product. I'm searching something like this: if(have_subscription){ //code to add button }else{ // code to add something else } I have no ...
0
votes
1answer
29 views

How to register a menu based on a ACF condition

I am trying to register a Wordpress menu, depending on a ACF field condition. $logo = get_field('logo','options'); if ($logo) { register_nav_menus(array( 'brand_centered_left' => __('Brand ...
10
votes
5answers
335 views

Best way of passing PHP variable between partials?

I have a variable in header.php, such as: $page_extra_title = get_post_meta($this_page->ID, "_theme_extra_title", true); Once I do: var_dump($page_extra_title); I always get NULL outside of ...
1
vote
1answer
25 views

Add get_option to jquery

I have created a settings page that contains various radio button options for a custom plugin. A radio button I've created is to 'display dots' with the values yes or no. I can get use the value any ...
0
votes
0answers
37 views

How can I add recent posts to menu like mashable

I would like create a mega menu that uses recent posts for hover state. Like When you hover a submenu you get a list of recent post relevant to that menu item like in Mashable. I I would like a menu ...
0
votes
1answer
51 views

What is wrong with functions.php? Fills error log with same error

After a third-party developer was used to reconnect our calendar with the Google Calendar API 3, we found that our .../wp_admin/error_log infinitely wrote: [14-Apr-2015 11:46:59 America/New_York] ...
1
vote
1answer
3k views

How can I customize wp_footer, where is the code that controls what this function does?

I am using Wordpress 2013 theme as a starting point for a new theme from scratch. Under my themes folder, my footer.php theme looks like this. (Notice the final functionwp_footer(). ...
4
votes
5answers
5k views

Relative URLs and hide /wp-content/themes/

in my header and other sections I would like to use <script src="/incs/js/script.js"></script> While maintaining the default theme folder structure in server as below ...
0
votes
0answers
91 views

function get_page_permastruct() on a non-object

global $user_ID; $page['post_type'] = 'page'; $page['post_content'] = "Hello world"; $page['post_parent'] = 0; $page['post_author'] = $user_ID; $page['post_status'] = ...
0
votes
1answer
27 views

Function returning queried meta value based on current post ID

I have written several queries which sums download counts grouped by the post they are associated with, and other relations. They work great for exporting to CSV and other uses outside of WordPress, ...
0
votes
1answer
375 views

Custom attributes to javascript tags

My site uses cloudflare but I really want to enable rocket loader, but if I put it on automatic mode, it messes up my whole site... So I googled and found This answer which has helped in terms of ...
0
votes
1answer
31 views

Conditional read more adjustment

I get the read more link like this <?php the_content("Read More"); ?> I want on the Homepage a different text than on an archive pages. I can change the text for all read more links in ...
0
votes
1answer
44 views

Wordpress get_post_meta issue

I'm new to php and was assigned some code to fix within a Wordpress theme, but I cannot figure it out for anything. The code is for the home page of a custom theme and it is supposed to pull the most ...
0
votes
2answers
34 views

Generating dynamic css into custom file [closed]

This is about running code on wordpress . The given code runs properly outside wordpress but when I put it on theme functions file it does not do anything. ob_start(); require('dynamic-css.php'); ...
1
vote
1answer
134 views

Understanding and altering the structure of posted images

Currently this is the (default) Wordpress image output: Float left, with caption, link to img <figure id="attachment_10220" style="width: 167px;" class="wp-caption alignleft"> <a ...
0
votes
1answer
71 views

Woocommerce Price Text

I'm trying to show after the price of my product, whether the price is 'per person' or 'per group'. I've created a custom field for both, so for example, if custom field 'price_per_person' is ticked, ...
0
votes
1answer
35 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
2answers
283 views

Can I show also the post date using the wp_get_archives() function?

I am pretty new in WordPress theme development and I have some doubt about the wp_get_archives() function: http://codex.wordpress.org/Function_Reference/wp_get_archives In my website I have create ...
0
votes
0answers
14 views

Running wp_schedule_single_event on Post Import

I'm trying to have a category deleted after a certain length of time once a post has been published. I was successful in doing this when a post is manually created, but I cannot for the life of me ...
0
votes
1answer
16 views

get_template_directory() - references parent theme directory

I've got this line in the functions.php of my Child theme: require ( get_template_directory() . '/somecode.php' ); However it's giving me the following error: Fatal error: require(): Failed ...
0
votes
0answers
78 views

AJAX login without a plugin does not work. when add a action to function.php

I am using wordpress ajax login without a plugin. I want to not be allowed users access to the WordPress profile after login, Because i have designed a specific profile in the link: ...
0
votes
1answer
14 views

Writing editor content to a file

I have a project I'm working on where I need to write the content of the post editor to a physical file on the web server when a post is saved or updated. I'll be parsing and manipulating the content ...