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)

0
votes
3answers
400 views

Global custom meta box

I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code. Currently I have: add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', ...
0
votes
2answers
196 views

I've got a function that auto creates taxonomy terms - Can it auto delete them as well?

I've got this inside my functions.php file. function add_product_category_automatically($post_ID) { global $wpdb; if(!has_term('','product_relation',$post_ID)){ $cat = ...
1
vote
1answer
323 views

Generating add_settings_section() calls dynamically

I have some pieces of code within functions.php that I could easly replace with much shorter functions, like, for example: function register_sections() { add_settings_section('SOMETHING_settings', ...
0
votes
1answer
512 views

is_page() or is_single not working

Im trying to clean up my scripts and I'm using a function to but ran into a problem with using both !is_page or !is_single to only show certain scripts on singles and pages. What did I do wrong here. ...
0
votes
2answers
4k views

Post Pagination Showing Same Posts Every Page

So I have this blog that filters by category Then by city. Somewhere while creating the filtration I broke the pagination which seemed to work fine earlier. It doesn't work on my homepage where it ...
1
vote
1answer
737 views

Auto-remove custom field with no value on publish

I got some plugins that auto-generates custom fields. Does anyone know how to automatically remove empty custom fields from post when I press "publish"? A check I can put in my functions.php that ...
0
votes
1answer
992 views

Enqueue script on every page except one

I want to load my javascript and exclude 1 page, so I tried the following without success: function mypage_scripts() { if ( !is_admin() ) { wp_deregister_script('jquery'); ...
0
votes
1answer
83 views

include w_thumbnail_src in function?

I got a function that automatically creates a custom field in the post. I have this located in my functions.php. Image is the name of the custom field and HERE is the value. How can I put the ...
0
votes
2answers
74 views

implementing a centralized content “show-do-not-show” toggle?

I have many custom templates for different post types, and I am manually inserting a social share bar inside the 'entry-meta' footer in each of those templates. I need a simple centralized way to ...
2
votes
2answers
3k views

How do I “unhook” / de-register jQuery so that it's not called as part of wp_footer();?

I need to "unhook" jQuery from my wp_footer() ... it's being called automatically and I'm looking for something I can add to functions.php which prevents it from being called a second time in the ...
0
votes
1answer
110 views

grab or load text on demand

What i want to do I want some content (could be stored any where in a post or custom field) to load only when the user clicks for it to load. This content could be any thing (text,images,html etc) ...
0
votes
1answer
65 views

Calling Custom Field within Function wrapped with Divs.

Hi all I've created a function that basically allows the user to input the embed code for youtube into a custom field called youtube and this will then be styled on a wordpress post. Now I can get it ...
1
vote
1answer
338 views

What is the “icon” parameter in wp_get_attachment_image_src used for?

On the reference page for wp_get_attachment_image_src, there is a parameter called icon and it only says: $icon - (bool) (optional) Use a media icon to represent the attachment. Default: false ...
0
votes
1answer
557 views

Remove default post types on all sites except primary blog. WPMU

I'm trying to come up with a solution that would allow me to remove the default post types (pages, posts, comments, links, etc) from all the multi-site blogs EXECEPT the primary blog. It will remain ...
0
votes
2answers
168 views

Change div background acording to the selected category

I'm coding a graphic menu that consist in five divs with a background each. On mouseover the background changes and the child div disappears. On click, each one works like a link to the correspondent ...
2
votes
1answer
2k views

Why is my custom meta box input not saving

I've added the following function to functions.php to add a custom meta box enabling the end user to input a gallery shortcode. I then intend to use this to place a gallery in a specific place on the ...
0
votes
1answer
1k views

Wordpress multisite,use same cookies across all website?

Hi is this posible to use same custom cookies across all blogs?Can someone help me with this?
0
votes
2answers
486 views

custom post type metaboxes not saving

I have the following code. I am trying to enter data into the custom metabox and then save it. When I go to view it has entered a post, however the name column has nothing in it. Also when I hit save ...
0
votes
1answer
50 views

Space Not Being Generated in HTML Output?

I'm using a code called custom_link_pages to generate my multiple page post links, but I'm getting a space between my page numbers and previous link, but my next link is missing the same space. ...
3
votes
2answers
247 views

Override default cropping in Wordpress [duplicate]

Possible Duplicate: How can I make add_image_size() crop from the top? Is there any way to have cropping happen from the center point in an image? All of my Featured Image uploads are ...
0
votes
1answer
490 views

Add title & subtitle to shortcodes

Is there a way I can add a custom title & subtitle to this shortcode function? function spoiler( $atts, $content = null ) { return '<div class="moreinfo"> <h3 class="click drop ...
0
votes
1answer
194 views

Tags break custom Excerpt function

Quick question here. I have a function that echoes out the post-type's content (if none available, the excerpt). It looks like this: function era_excerpt($post, $length = 11, $ext = ' ..') { ...
0
votes
1answer
554 views

update_user_option not working as expected

So I was looking into the update_user_option() as I need to update an additional field upon registration. So I found this in wp-login.php: update_user_option( $user_id, 'default_password_nag', true, ...
0
votes
1answer
605 views

Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()

i have add facebook opengraph tag now it showing error like Call to undefined function wp_get_attachment_src() Object at URL 'http://www.website.com' of type 'article' is invalid because the ...
0
votes
1answer
84 views

Post variables not displaying correctly in custom function

There seems to be something wrong with the simple function below, but I can't figure out what it is. It is displaying as the following and I can't figure out why. I know it has something to do with ...
0
votes
1answer
776 views

Is it possible to display a DIV to not logged in users and then change it for users who are logged in?

Basically I'm putting together a magazine site that wants a strong focal point on the homepage for users who haven't signed up, if the user is logged in we need this content to show something else, is ...
4
votes
1answer
7k views

Add custom template page programmatically

I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code: global $user_ID; $new_post = array( 'post_title' => 'Test ...
0
votes
1answer
96 views

new post-type how do i retain the plugins on my sidebar?

I created a new post-type following this technique: (http://www.wpbeginner.com/wp-tutorials/how-to-use-custom-post-types/) After creating a a new post-type some of the feature of the a regular post ...
1
vote
1answer
239 views

Custom random quote widget breaks when used in multiple sidebars

I've created a custom widget and placed it in functions.php. You can see the widget here: http://pastebin.com/3uWpeaFx (I've also created a similar widget that grabs a random image; it's included ...
3
votes
2answers
4k views

wp_register_script not loading as expected

I am loading scripts like this: //load scripts //wp_register_script( $handle, $src, $deps, $ver, $in_footer ); add_action('wp_enqueue_scripts', 'load_scripts'); function load_scripts() { if ...
2
votes
2answers
5k views

delete uploaded file

I have a function wp_handle_upload() for uploads files. $file = $_FILES['attachment_icon-' . $i]; $upload = wp_handle_upload($file, array('test_form' => false)); what is a function for delete a ...
-3
votes
2answers
2k views

Removing the default sidebar from admin panel

I would like to remove the default sidebar from my template, it is not needed and I do not want to confuse the user that will be using the admin panel. I have created my own sidebars that are a bit ...
0
votes
1answer
121 views

Run a function when post is deleted?

Is it possible to run a function every time a post is deleted. The function has to be run when the post is deleted from the admin or by the wp_delete_post() function.
0
votes
1answer
261 views

Setting post_id for single.php based on URL without a redirect

I'm migrating a Joomla! database to Wordpress and the website has to remain exact regarding URLs. The Joomla site has its posts with .html extensions, and the importer I created maps the Joomla file ...
-1
votes
1answer
520 views

wordpress Search function is not working

My wordpress Website Version is 2.8.1,This is the Custom wordpress website done by 2 years ago.[Link Removed... i got Solution][1]Now Search functionality is not working(It was working well earlier.) ...
1
vote
1answer
53 views

Include default functions and methods

I'm starting a new service for a customer consisting in adding a input API in their WP website. I started by creating a blank page on the root but then I realized I couldn't access all methods and ...
0
votes
1answer
90 views

loading custom.js file after jquery is loaded

I am adding a javascript file through the functions.php file. I am using the method as suggested on Wordpress Codex. One question I have is that what is the best way to handle the version number ...
2
votes
3answers
2k views

Creating a table from shortcode avoiding wpautop for each row

I'm probably doing this all wrong, and there'll be a much simpler solution. Basically, I'm trying to build a table of tour dates that'll be editable by someone with little technical knowledge, but can ...
0
votes
2answers
119 views

Functions.php Problem

When I add lines 3 - 19 to the top of functions.php, then try to update image.php I get the error "Warning: Cannot modify header information - headers already sent" when I try to update my image.php. ...
1
vote
0answers
35 views

Can i attach a post specific tag to a comment? [closed]

I would like to be able to have the comment "waiting for approval" mailings display the blog they came from. I.e, if a comment is left for approval from "eating fish" the mail message ought to ...
0
votes
2answers
204 views

adding custom script to functions file

I have a problem adding a custom script to my functions.php file: add_action('wp_print_scripts', 'load_AJAX_URL__'); function load_AJAX_URL__() { wp_localize_script( 'ajax_URL', 'MyAjax', array( ...
2
votes
5answers
680 views

Code in theme functions.php faster than with a plugin?

I've read many articles that says that we should not keep plugins that we don't use. Even if they are disabled, they use memory. functions.php instead of 10 plugins? What if i have 10 small plugins ...
1
vote
2answers
781 views

Display gallery on top before content

Is it possible to execute the gallery shortcode before any other content no matter where the shortcode is in the post HTML?
0
votes
4answers
3k views

Remove Page Title from Static Frontpage

I'd like to remove the post title from my static frontpage. Just that page. I've created a child theme from a free Press75 theme. So I'd like to make this change in my child theme's function.php. I ...
-1
votes
1answer
75 views

Removing title from page

Hello attempting to remove the title from static front page using the following code is (not working) in my functions.php function remove_page_title() { if (is_front_page() ) { add_filter( ...
0
votes
2answers
896 views

Echo custom field value in shortcode function

I must be doing something wrong here. I want to display the custom fields "pw_featured_note" & "pw_featured_price" Here is my code so far function featured() { ...
0
votes
1answer
91 views

A better way to get stats

I'm not looking for an specific answer but more of a general direction. Recently I decided to make my own stats plugin. I know there are tons out there, but I wanted to make my own. I figured, how ...
0
votes
2answers
249 views

Don't display html if function returns nothing

This question is very similar to the one below however it requires a different solution. Don't display html if custom field is empty I'm using the plugin Related Posts Thumbnails but i'm using ...
2
votes
3answers
1k views

How to add .htaccess code through a function?

I need to add the following .htaccess code through a function <IfModule mod_deflate.c> # Insert filters AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html ...
1
vote
2answers
904 views

Remove category from url

I want to remove /category/ base from the permalinks. I tried the solution ...