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
1answer
101 views

Does code run faster in functions.php than in different theme templates?

For example I have this code which gets the post title: function baracuda_sinlge_post_title(){ // Single Post Title $post_title = single_post_title('','0'); return $post_title; } ...
2
votes
2answers
2k views

How to register images uploaded via FTP in media library?

I'm using my own upload.php file to upload images to: $upload_dir = wp_upload_dir(); $targetDir = $upload_dir['path'].'/'; It works like it should with this exception that images uploaded to ...
0
votes
1answer
126 views

Post type Echo code is repeating on homepage

Hi i'm using this php code that allows me to call a div in different post type, but the only problem is when i add a second line instead of it showing only on the post type page it shows on the home ...
1
vote
1answer
864 views

Enqueue styles after a plugin

Is there a way to enqueue my style.css (and other stylesheets) AFTER a certain plugin enqueues its styles? Specifically, I want my style.css to overwrite cforms's styles, but when I change the ...
1
vote
1answer
52 views

Run wp_kses_decode_entities on atom feed?

I would like to convert the htmlentities in only my atom feed to their corresponding characters. Using the below in my functions.php I've gotten close, but obviously the commented out line doesn't ...
1
vote
2answers
6k views

Limit access to posts/pages by user roles

I'm looking for a way to protect content by user roles. Example: you have to be registered to view posts (frontend). If a user is a subscriber he can read post 1, 2 and 3, but if the user is a ...
2
votes
1answer
2k views

How to manually activate user in dashboard only by admin

I'm looking for a function that allows admins (only) to activate new users. When a user registers he have to be approved by the admin before he gets access to log in. Does anyone know how I can do ...
0
votes
1answer
209 views

Invalid Taxonomy in template

I have looked through the posts here that involve this same error, without any luck. I have a Custom Post Type (Staff) and a custom taxonomy for it. Making Staff posts and assigning terms is working ...
1
vote
1answer
516 views

Display tags that only appear in one category

I'm trying to get this less manual than it currently is. I want to display tags that appear in only a single category, so if they are in a post that has two categories, I want that tag ignored. The ...
3
votes
2answers
553 views

Default content for a post in one category?

This is a common function that adds default text to all posts: add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = "default content goes ...
3
votes
2answers
3k views

How to detect single.php (but not single-portfolio.php)?

When I'm using is_single(); in my <head> section to add some style to website navigation it executes correctly on blog posts but it also executes on single "portfolio" post type posts (so ...
0
votes
2answers
2k views

Get the 5 lastest Featured Posts from a category

Here is the website http://ariadneswonderland.gr/ that all this concerns. On the homepage I'm using a Drop shadow box plugin under the gallery to show a series of images of featured posts, as of ...
-3
votes
1answer
1k views

Missing argument 2

Hi just looking for help with this cant solve this Thanks Missing argument 2 for t2t_homepage_slide()XXXXXXX/index.php on line 41 and defined in/xxxxxxx/ten.php on line 94 <?php ...
0
votes
2answers
2k views

Using “Read More” link with custom excerpt

The following functions.php edit (contributed by helgatheviking on the themeshaper forums) allows the use of a "Read More" link with custom excerpts. My problem is simply this: I'm inept at editing ...
1
vote
0answers
97 views

Function to update post_meta based on existing post_meta

I have a custom post type for addresses on a Google Map. One meta field is for the address, but I want to convert that address to longitude/latitude. So I have a meta field for longitude & one for ...
1
vote
1answer
536 views

how to call a function only in specific pages and exclude it from other pages

I have the below functions require_once(GABFIRE_FUNCTIONS_PATH. '/review-options.php'); require_once(GABFIRE_FUNCTIONS_PATH . '/custom.php'); require_once(GABFIRE_FUNCTIONS_PATH . '/shortcodes.php'); ...
1
vote
1answer
974 views

wp_nav_menu, walker class, categories as classes of li

OK I'm trying to show my principal menu so I use the following code: <?php $defaults = array( 'theme_location' => '', 'menu' => '', 'container' => false, ...
1
vote
2answers
4k views

If category is in parent category?

I have function that check what is main top category of post. So i have category tree like this Foo -bar --foobar cat2 and if post is in foobar, my function post_is_in_descendant_category shows me ...
3
votes
3answers
1k views

Child theme functions.php do I use php open and close tags?

I setup a child theme which works fine. It's importing the main style.css and has custom css styles along with custom header.php and footer.php files When using functions.php in a child theme it's ...
0
votes
1answer
76 views

Give a function a unique ID

I'm developing a theme that uses a Twitter Tweets custom widget (Not coded by me). There are several widget areas within the theme and if I try and include the Twitter widget in say the sidebar and ...
0
votes
1answer
437 views

Using add_image_size in functions.php to get original uploaded file

It is possible to use add_image_size in functions.php to get the original uploaded file size. Because when I uploaded the images to my posts I cropped them in order to have 1x1 ratio for all my image ...
1
vote
0answers
38 views

remove class from code [closed]

How can I remove the class from the following code and use it without the functions. I tried removing the functions and class and add it in functions.php but it did not work. class someclass { ...
1
vote
1answer
2k views

Getting the post_id in wp_ajax function

I wrote a custom AJAX function in which I have assigned a post type to be a child of another post type. In one function I am looping through those child posts, and I want to update the database to ...
1
vote
1answer
176 views

Hard-coding custom menu elements for menu manager

I realize that one can add custom links through the menu manager but is there a way to manually create such components through the functions.php file? More specifically, one example here relates to a ...
1
vote
1answer
917 views

RSS Feed has no styles in chrome - function to add one?

This is a really bizarre problem. For some reason Chrome does not have any RSS feed formatting? Where as most other browsers do! So it seems from I read online that I have to create my own style ...
0
votes
1answer
65 views

Allow authors to create article image

I want to allow contributors to upload images while creating posts. But the catch is, I am building the post display pages out of my own custom PHP. Every article written will follow the same ...
0
votes
2answers
71 views

Way of getting queried loop before the query with a filter hook?

Is there a way to get the results of a loop with a filter before the code for the loop is performed in the structure of your code? My markup is something like this: <body> <div> /* ...
1
vote
1answer
142 views

If in category to be inside of a function

I have this code in WordPress index.php and I was wondering how can I transfer this in to a functions.php to be a part of a function? <?php if (in_category('featured')) : ?> <a ...
1
vote
2answers
2k views

class=“parent” for wp_list_pages?

<div class="menu"> <ul> <?php wp_list_pages('exclude=&title_li='); ?> </ul> </div> creates the following output... <div class="menu"> ...
1
vote
1answer
183 views

Shortcode with custom content attribute?

I am creating a shortcode for a client site that should display an image and a saying (mainly at the bottom of the page, but basically wherever the client wants to insert said image/saying). The ...
0
votes
2answers
392 views

get_image_tag() html output : empty src attribute

I'm trying to use the get_image_tag() function to alter the html output of an image, like so : add_filter('get_image_tag', 'kh_image_attachment', 10, 5); function kh_image_attachment($html, $id, ...
3
votes
2answers
2k views

How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?

I would like to create a condition that checks to see if a post has a thumbail and if it does display it, otherwise display the first image in a post. I tried something like this in my loop.php but ...
-1
votes
2answers
65 views

How do I add e-mail subscription functionality

Hi I am new to wordpress. Kinda going through different themes that is available. I like on, which is Oulipo, but it doesn't have any e-mail subscription feature. I am using free wordpress hosting. I ...
0
votes
1answer
182 views

Menu not styling. New menus functionality giving me a headache

I can't find a good tutorial on the new menu handling functions, and the ones I found don't seem to work for me. What am I doing wrong? In my functions.php: (I'm using the Blank Slate theme as a ...
0
votes
1answer
1k views

Use a shortcode to display custom meta box contents

Is this possible? If so, can someone point me towards a clear tutorial? I have a column of content I want to float right of the_content, so I'd like to be able to use a shortcode to put that content ...
0
votes
1answer
641 views

Displaying Saved Meta Box Data in Drop Down with selected()

I have a custom meta-box for certain custom post types, and one of those fields in the meta-box is a drop down. I am providing the field correctly, saving the information, and even calling it ...
0
votes
1answer
331 views

Multiple, Dynamic, Sidebars Problem - First Sidebar not working properly

This is my function: function ec_register_sidebars() { register_sidebars( 3, array( 'name' => 'Sidebar %d', 'id' => "sidebar-$i", 'before_widget' => '<li id="%1$s" ...
2
votes
1answer
504 views

Plugin Uninstall and Deactivate via Options Menu

I'm creating my first plugin (modifying an existing one for what I need) and although it's working fine i am trying to create a simple options menu to allow either deactivation of the plugin, or ...
1
vote
1answer
37 views

How to select a page within admin?

How does one apply an action to one particular page within admin? I've added a bunch of wysiwyg editors to one page ("Home") and now I don't need the main editor. But the function below - of course - ...
2
votes
3answers
846 views

Pinterest Integration Using functions.php

I use a theme to build an portfolio. I´d like to add an pinterest "pin-it button" into the fuctions.php: Facebook, Google+ an Twitter were done, just the pinterest won´t work. Can´t found the the ...
0
votes
1answer
133 views

Custom Query Not Paginating

I have a site that uses a custom query to filter posts: <?php //Search Region table to retrieve array of country names $regionresult = mysql_query("SELECT * FROM gallery_regions WHERE ...
0
votes
1answer
240 views

Load Javascript from Plugin in One Page Only?

I use the ALO EasyMail Newsletter. But the plugin is loading lots of Javascript in the head. I have a mobile site and the scripts are loading in all the pages. I think this affects the mobile ...
0
votes
1answer
94 views

Retrive post by tags PHP code

For example, i am building a cinema site.. For movies - I am using post - The movies are post there.. For actors - I am using post_type : persoane , Taxonomy : lista. How can i retrive the movies ...
0
votes
1answer
354 views

WP Custom Comment Callback Not Responding

I have a client site that has requested a custom comment format for posts of a specific category. In my loop template, I have this: <div id="gallery-commentlist"> <ul ...
4
votes
1answer
2k views

wp_get_attachment_image returns different image size

It is a bug? wp_get_attachment_image( $attachment_id, 'post-thumb-size-small'); Same code, called in template, and in AJAX call returns same image SRC, but different image width and height. dumb ...
1
vote
1answer
365 views

Load jquery only for certain pages in the backend

I have a set of custom theme settings in my functions.php file. In order to arrange some things I want to load jquery ONLY to my functions.php file. What I read in wordpress is this: If it was ...
0
votes
1answer
521 views

Replacing global wp_query

I have a site that uses a custom query to search for posts by country. The search results come back fine, but the pagination at the bottom reflects the total number of posts in the site, instead of ...
-5
votes
1answer
135 views

MIssing feature image link function

I need to be able to add a feature image to a post as a link. The link is good, it's green check. And no i cannot upload the file and insert into post dont do anything good. I have the link to the ...
-2
votes
1answer
544 views

How do I access variables outside a function [closed]

I have a custom function which defines a bunch of variables. I would like to be able to call this function from inside a loop so I can have access to all its variables, like so: functions.php ...
1
vote
2answers
2k views

PHP Fatal error: Call to undefined function plugin_basename

I'm receiving this error: [27-Jun-2012 18:22:39 UTC] PHP Fatal error: Call to undefined function plugin_basename() in /XXXX/public_html/wp-content/plugins/price-update/price-update.php on line 68: ...