question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
How can I do that? So far the admin can only add exisiting users.
To follow up to xLRDxREVENGEx's answer, here's a screenshot of the checkbox you need to check in the network admin section:
I'm a super admin and I want to give an admin the ability to add new users...?
wordpress
it is causing problem because i did not do it before. I am trying to enqueue style or may be scripts depending on page. But it not working. Here is the code: <code> add_action('init', 'my_enqueue_styles'); function my_enqueue_styles(){ if(is_page('Add Event')){ // also tried slug, page id and wp_reset_query(); bot not ...
It should work like this. Sidenotes: I don't know why you deregister a stylesheet and register it again. Also: <code> get_bloginfo('template_directory') </code> is now replaced by <code> get_template_directory_uri() </code> . Third: Are your folders really named with dots in between? Maybe this causes problems. And may...
Enqueue Style for a page/pages only
wordpress
Anyone have recommendations for wordpress plugins that can scale easily and integrates with Wordpress' new custom post types? Not interested in themes as discussed here: stackexchange-url ("Real Estate website with Word Press")
Ended up going with something custom in drupal. Seems like the best way to go.
Wordpress plugin for real estate that scales?
wordpress
I'd like to have a static home page and also have a link called "Blog" that lists posts in the "blog" category in chronological order. Would the best way to do this just be to place code in archive.php and do a "switch case" on the category and do a loop on the posts? Just looking for some options before I decide on a ...
wp dashboard > 'Page' > add new > name it 'Home', publish wp dashboard > 'Page' > add new > name it 'Blog', publish wp dashboard > Reading Settings > 'Front page displays' select 'a static page' set 'Front page' to 'Home' page that you have added > set 'Posts page' to 'Blog' page that you should have added. It doesn't ...
Static home page with "Blog" inside?
wordpress
When a user enters a page I want to check if he is logged in. How can it be done in the page's template? Or is it possible only in functions.php or a plugin?
<code> if (is_user_logged_in()) { echo 'You are logged in. Yay!'; } </code> Codex: <code> is_user_logged_in() </code>
Is it possible to use WordPress functions in a page template?
wordpress
I added a link to a PDF in my custom navigation menu. Is there a way to force it to download instead of open?
If you don't mind all PDF attachments been forced to be downloaded then you can use something like this: <code> &lt;?php if (have_posts()) : while (have_posts()) : the_post(); $pdf_title = $post-&gt;post_title; $uploads_dir = wp_upload_dir(); $attachment_src = get_post_meta( $post-&gt;ID, '_wp_attached_file', true ); $...
Force PDF download from custom menu?
wordpress
I'm pretty new to WordPress... I'm trying to set up a few sites, each with their own top level domain name. What I want them to do is share some of the pages, but not others. For example - they would all share Services, Contact, and Team pages; but would each have their own Biography page. When one of the shared pages ...
I do not believe this is possible. The only way is to create the page in each site or add a custom link to one main page but doing this will show only that sites theme
Multiple sites that share some pages, but not others
wordpress
I have a custom post type created called 'missions'. When developing the site on my Dedicated Virtual, I had no problems. But I moved the site to a shared hosting grid server (mt) and now receive this error through out the admin. Warning: call_user_func_array() [function.call-user-func-array]: First argument is expecte...
what's the add action at the bottom doing? It's not required for setting up CPTs, just the setup bit you have running on init.... I believe that is what's throwing the error I have to make it an answer. It was a suggestion, but if it worked for you, I'll make my comment an answer, then you can accept it!
Custom Post Type Causes Error: Warning: call_user_func_array()
wordpress
I've already found out stackexchange-url ("here") how to remove the row-actions from the posts table in wordpress admin. Now I'd like to do the same in the pages table. I've looked in the core files but, well, I just don't get it. Anyone? Here's the code used in functions.php to remove row actions in posts: <code> func...
For non-hierarchical post types the filter is called <code> post_row_actions </code> , for hierarchical it's <code> page_row_actions </code> . If you want to remove all actions you don't have to unset the individual items, you can just return an empty array. <code> add_filter( 'page_row_actions', 'wpse16327_page_row_ac...
How to remove row-actions from pages table?
wordpress
I need your recommendation for the best practice here: A custom post type I have created needs a list of attachments at the end of the post content. I have created a series of functions that handle displaying the list of appropriate attachments for a post. I don't want to use shortcode to insert this attachment list, s...
<code> &lt;?php // A) // inside your template if ( function_exists( 'the_attachment_stuff()' ) ) { // do stuff } // better/faster if ( class_exists( 'attachment_plugin_class' ) ) { // do stuff } // B) // inside your template do_action( 'the_attachment_suff'); // means setting this inside your plugin // this avoids thro...
Best practice for including plugin output in a template without using shortcode?
wordpress
I am building a front end post layout editor using jQuery UI Sortable. The posts are laid out in 300px by 250px boxes over a background image. The posts are created and edited using the WordPress admin but I want to allow the sites administrator to adjust the order of the boxes using a drag and drop interface on the fr...
Brady is correct that the best way to handle saving and displaying of custom post type orders is by using the <code> menu_order </code> property Here's the jquery to make the list sortable and to pass the data via ajax to wordpress: <code> jQuery(document).ready(function($) { var itemList = $('#sortable'); itemList.sor...
How to save the state of a drag and drop jQuery UI Sortables front end layout editor?
wordpress
TwentyTen adds some classes to custom menus, for instance: <code> #access #menu-item-262.current-menu-item, #access #menu-item-262.current-menu-ancestor </code> All the top-level links in my primary navigation have the class <code> .current-menu-ancestor </code> when the user is on a child page -- except when I'm viewi...
The classes are not added by the Twenty Ten theme, but by the common custom navigation menu code, in <code> _wp_menu_item_classes_by_context() </code> , which is called from <code> wp_nav_menu() </code> . If you want to add extra classes you can do that by either hooking into <code> wp_nav_menu_objects </code> , called...
adding .current* tags to custom post types and taxonomies
wordpress
I currently use WordPress for most of my projects, the way I manage them is creating a folder for each in my local environment each containing a WP install which in times makes it a paint to maintain, upgrade and takes more space. I was looking at WP Multisite and I was wondering if I could use it to create multiple pr...
Export/Import like you would the data for any other WordPress install: On the development site: <code> Dashboard -&gt; Tools -&gt; Export -&gt; All Content </code> (save file) Package up the Theme files as "theme-name.zip" Make note of any custom settings On the live site: Install the custom Theme `Dashboard -> Tools -...
Using WordPress Multisite to manage multiple projects?
wordpress
Ive been experiencing a problem with the new WordPress 3.1.2 update. When i use <code> add_theme_support(); </code> and register an array of post formats, it registers all of them fine, but when it comes to the video post format, it registers it twice, and gets called post-format-video-2 . This is the way im writing ou...
Thanks to @goldenapples and @kaiser for their guidance. Apparently (for some odd reason) i had two terms registered with post-format-video. Im not sure if the following can be a viable solution to the problem, but i fired up Workbench and deleted both rows in the wp_terms table. I then reloaded the local site, created ...
Wordpress 3.1.2 Bug: add_theme_support() and video post format registering twice
wordpress
"Insert search engine here" was pretty useless for this one - I've had a look through <code> wp-includes/functions.php </code> , <code> wp-admin/includes/file.php </code> etc. but not found a reason for the behaviour I'm getting. I'm running multisite, and when I upload a .doc or .pdf I don't have a problem. When I upl...
Found it while digging around in multisite network admin settings: there is a setting called "Upload file types" (in the database it's the row with <code> meta_key </code> = "upload_filetypes" in the <code> wp_sitemeta </code> table) which contains a list of allowed filetypes. Adding "ppt" to the list allows them to be...
Can upload doc and pdf but not ppt - not permitted for security reasons
wordpress
In BuddyPress, when a user clicks on their username, they are presented with a page that contains a menu: <code> Activity Profile Messages Friends Groups Settings </code> How do I add an item to this menu? How do display this menu inside my template? (The default page template only displays the main navigation.)
Here's an example of adding a menu items pointing to custom templates. If you want to link to existing BP elements, you'll need to look up the appropriate action. Add this to <code> functions.php </code> : <code> // Set up Cutsom BP navigation function my_setup_nav() { global $bp; bp_core_new_nav_item( array( 'name' =&...
Add BuddyPress Profile Menu Item
wordpress
I have 3.1.2 running with the Boldy theme. Site link. I have a menu that has a number of external links listed in the items. By default, these items do NOT load in a new tab/window. There is no option in the Admin --> Appearance --> Menus, to tick a box to say open in new window. How do I get them to do this?
In your WordPress admin panel, go to <code> Appearance &gt; Menus </code> . Select <code> Screen Options </code> in the top right corner. Enable the property <code> Link Target </code> . Now you can set your link target element in your external link.
Menus - Open items in new tab/window?
wordpress
Is there a theme or some hack of the categories system that I can use to create a site for a podcast network? I want it similar to This Week in Tech in that all the podcasts will appear on the front page, but also each have their own homepage. I do not think a multi-site installation will be my solution. Each podcast m...
Any Theme will do, for the most part. Simply install the Blubrry PowerPress Plugin or the podPress Plugin , and away you go!
Wordpress for Podcast Network
wordpress
I am building a template where wordpress is being used primarily as an image CMS, I am pulling the first image from the content section of each post. <code> &lt;img src="&lt;?php echo grab_image() ?&gt;" /&gt; function grab_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_matc...
Use <code> get_children() </code> ( Codex ref ): <code> $images = get_children( array( 'post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC' ) ); </code> The first image will be <code> $images[0] </code> . EDIT: And by "first ...
Pull images from the gallery
wordpress
I'm using More Fields plugin, and when I use my functions.php to embed the custom field, I get an odd issue. The field value is followed by a "1" I use this code: <code> //Address add_action( 'woo_post_inside_before', 'my_address' ); function my_address() { global $post; if ( is_single() &amp;&amp; in_category('listing...
There is no WordPress function called <code> meta() </code> . Try using <code> get_post_custom() </code> ( Codex ref ) instead. For example: <code> //Address add_action( 'woo_post_inside_before', 'my_address' ); function my_address() { if ( is_single() &amp;&amp; in_category('listings') ) { global $post; $meta = get_po...
Odd functions.php issue in Wordpress
wordpress
Since I am pretty new to WP and the whole stuff i ran into a problem. I am using the pretty-well known "Lightword" Theme. And today i've upgraded to the newest version. It's now possible to add/edit the menu items through the theme-settings. Although I like this very much I am not able to display more than one addition...
You are trying to display multiple menu items, or multiple menus? Each theme supports a certain number of menus. Your's may only support one menu, that is the menu position. You create a menu to go there. From withing the menu creator interface you put all the items you want to appear on your menu. You can even nest it...
Lightword Theme - only one menu item
wordpress
At the moment my users posts are only viewable to them. I would like to implement a system where they can choose to share any post with other users they know. The problem I'm having is, how do I make the connection between users? The best I came up with is to create a table in the db and store their friends by user id'...
BuddyPress can be used as a framework - it allows you to friend other users, and is a good place to start from. [Update] This is the structure of the BuddyPress friends table (bp_friends) <code> CREATE TABLE `wp_bp_friends` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `initiator_user_id` bigint(20) NOT NULL, `friend_user...
How to implement friend system for Wordpress?
wordpress
I'm developing a theme where I'm using theme options to allow users to set various things -- text size, background colour, link colour, etc. The basic code I'm using for the options is in header.php and looks like this: <code> &lt;?php $options = get_option('mytheme_theme_options'); if( isset( $options['backgroundcolou...
Use standard <code> echo </code> or <code> printf </code> with additional parameters. e.g. <code> if(isset($option['borderradius']) &amp;&amp; (!empty($option['borderradius']))) { $borderradius = '.post { '; $borderradius .= 'border-radius: ' . $option['borderradius'] . 'px; '; $borderradius .= '-webkit-border-radius: ...
Using theme options to change a border-radius value
wordpress
I need a hook such that when visitor lands on any of the post (not page) , I need to record a hit. How can I find whether the request is for post, and is there any hook to find if the loaded content is post, and if yes, what is post id
something like this will work: <code> function record_hit_if_post(){ global $wp_query; if($wp_query-&gt;is_single==1) // single post's ID: // $wp_query-&gt;post-&gt;ID; } add_filter('template_redirect', 'record_hit_if_post'); </code>
finding whether request is for post, and post id
wordpress
I'm developing a a site using the wp e-commerce plugin, and it handles tags in pretty much the same way it would if I were using it for a blog instead of a store. The issue is that I want to use the tags as a secondary kind of navigation menu so that customers can view all items made from a certain material no matter w...
you can use <code> wp_list_categories() </code> to output an unordered list: <code> &lt;?php wp_list_categories( array('taxonomy' =&gt; 'product_tag') ); ?&gt; </code>
Making tags appear as an Unordered list instead of a 'cloud'
wordpress
OK so i am drawing a blank. I have setup a WordPress 3.1.2 Network site and want the main site to appear with www.mydomain.com not mydomain.com and i can get that to work but the back-end on the network admin breaks when i go to add a site it gives me the error "Are you sure you want to do this". When i disable the red...
Where are you trying to do the force redirect? I think the best place for this may be in a <code> .htaccess </code> file. Something like <code> RewriteEngine on RewriteCond %{HTTP_HOST} !^www.your_domain.com$ RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301] </code>
Wordpress 3.1.2 Network Enabled non-www to www
wordpress
I'm developing an online store using wp e-commerce plugin. Whilst working on it locally the problem didn't occur, but after I started testing it online a large gap began appearing before the top of the page. Using Firebug I've been able to see that the styling causing it is: html {margin-top: 28px !important; } which f...
This is almost surely your problem Wordpress Admin Bar ..
style being attatched to tag from outside of style sheets
wordpress
Currently I use: <code> query_posts("post_type=listing"); </code> to pull all entries of my custom post type. But I have a taxonomy called status with the values of Available, Pending, Sold. I only want to show Available and Pending on one page, and sold on another. How do I go about this? thanks!
There's the "tax_query" argument available since the latest wp release: <code> global $query_string; $args['tax_query'] = array( array( 'taxonomy' =&gt; 'status' ,'terms' =&gt; array( 'available', 'pending' ) // change to "sold" for 2nd query ,'field' =&gt; 'slug' ), ); $args['post_type'] = 'listing'; parse_str( $query...
Query multiple taxonomy in Custom Post Type
wordpress
and thanks in advance for your help. I've done some searching, and this question has been answered a couple of times with reference to the "posts 2 posts" plugin, but the documentation on that is very "coder-centric" -- I am able to and comfortable getting my hands dirty, but I do require better Step-by-Step documentat...
stackexchange-url ("Scribu's") posts-to-posts is a great and simple plugin, I'm sure we can help you get it working. The basic usage is pretty straightforward. assuming your custom post types are named <code> 'place' </code> and <code> 'event' </code> , the following code would go into your theme's functions.php file: ...
Linking Two Post Types
wordpress
While inside "the loop" in WordPress, is there an easy way to detect if a post is the most recent? A Usage Example: I want to make the first post output an H1 for the title instead of an H2. Or I want the first post to display a thumbnail image (and not the rest). Here is some pseudocode what I'm trying to get across: ...
In addition to @Milo Answer (this avoids a senseless query, because we already got every needed information from the current wp_query): <code> if ( have_posts() ) : while ( have_posts() ) : the_post(); $headline_html_tag = $GLOBALS['wp_query']-&gt;current_post === (int) 0 &amp;&amp; $GLOBALS['paged'] === (int) 1 ? '1' ...
While in "the loop", detect if a post is the most recent
wordpress
For some reason WordPress media manager is only showing 2 images per page? This is happening on 2 separate sites now and I can't get rid of it. Is there a way to manipulate items per page for the wp-admin media library?
thanks Jan - it was the 'more fields' plugin and the temp plugin fix is here; http://wordpress.org/support/topic/plugin-more-fields-media-library-only-shows-5-images-at-a-time-and-not-10?replies=10
Media library only show 2 items per page?
wordpress
I want to list all the users of my site and the amount of posts each user has. So far I have the function below, but I don't know how to pull in each user's ID to use in the count_user_posts... <code> &lt;ul&gt; &lt;?php foreach ( get_users('order=DESC&amp;orderby=post_count') as $user ) : ?&gt; &lt;li style="color:#ff...
WordPress has a wp_list_authors function with the option to list post count. <code> &lt;?php $args = array( 'orderby' =&gt; 'post_count', 'optioncount' =&gt; true); wp_list_authors( $args ); ?&gt; </code> EDIT: While it's possible to do it the way you're doing it and use count_user_posts(), this will trigger a query to...
How to list users and their post amount?
wordpress
I am new to wordpress, so if this question was already answered I apologize in advance. I have a search form in wordpress which looks like this: <code> &lt;form action="wordpress/action.php" id="search_form" method="get"&gt; &lt;label for="s" class="hidden"&gt;&lt;/label&gt; &lt;input type="text" size="30" id="s" name=...
While looking for possible pointers I found the SearchAutocomplete plugin , which seems to do what you want. You can see it in action at the site of the author .
Displaying search results in the widget itself?
wordpress
Is possible to get current-menu-item as a php variable? I'm listing the category museums via the menu item 'museums we support' so i'd like the get 'museums we support' bit and display it somewhere? Any help appreciated!
This is possible by filtering <code> wp_nav_menu_objects </code> , which is the easiest place to check which item is the current menu item, because WordPress already added the classes for you. <code> add_filter( 'wp_nav_menu_objects', 'wpse16243_wp_nav_menu_objects' ); function wpse16243_wp_nav_menu_objects( $sorted_me...
How to get current-menu-item title as variable?
wordpress
Here is what i'm having problems with... I want to link a youtube video to start playing in a lightbox/fancybox when a person clicks an image. Kind of like this site has - http://www.adroll.com/ - if you click the "Click to Play" (which is an image) a window will open (although not lightbox/fancybox) and video will sta...
Follow Tip #4: http://fancybox.net/blog . or I use Easy FancyBox for my wordpress sites. In the WP Admin, under Settings > Media you can edit the settings for Fancybox and it has a way to autodetect Youtube embeds.
Linking an image to open a youtube video in lightbox/fancybox in wordpress
wordpress
I got this error message when I was installing a plugin: "Unable to locate WordPress Content directory (wp-content)". I found a solution here: http:// wordpress.org/support/topic/cannot-find-content-directory-wp-content They suggested adding the following code to the wp-config.php file: <code> if(is_admin()) { add_filt...
The first part ( <code> add_filter() </code> ) tells WordPress to use the direct-write method. The second part ( <code> define() </code> ) tells WordPress to apply <code> 0751 </code> permissions to any directory it creates. More information here . I would not consider using the Direct Write method to be safe to use in...
What Does this Code Snippet Do?
wordpress
I am using wordpress 3.1. and I have to reorganize categorize my posts. For this purpose, I am willing to remove some categories. Therefore, after login to admin section of my blog, I go to post > posts > I select the articles I want to edit > I select edit option from "Bulk Action" select box > I select new categories...
Bulk category update (wordpress inclusive) just for adding more categories or to remove a category which is among all selected posts.
Bulk category update is not updating
wordpress
I'm setting up a widget that allows to add an image to a sidebar / widget area. Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's <code> functions.php </code> file using <code> add_image_size() </code> . Apart from the obvious ( renaming all the <code> add_image_si...
<code> &lt;?php global $_wp_additional_image_sizes; print '&lt;pre&gt;'; print_r( $_wp_additional_image_sizes ); print '&lt;/pre&gt;'; </code>
get_intermediate_image_sizes Get the Size Names but How Do I Get the Sizes?
wordpress
<code> //Geo Map add_action( 'woo_post_inside_after', 'my_geo_mashup' ); function my_geo_mashup() { global $post; if ( in_category('listings') ) { echo GeoMashup::map(); } } </code> Works to embed my map tag only on my single posts categorized as "listings" But, the embedded tag is also showing within the index of post...
<code> if ( is_single() &amp;&amp; in_category('listings') ) { </code>
functions.php conditional tag - only show in single.php?
wordpress
I am looking to embed several shortcodes into my post template, but I want the tags to be conditional to a specific category (and subcats). I've looked through the codex, but I'm unsure where to start.
If you're embedding the code directly into the template file, why bother with shortcodes? Simply extract the code from the <code> add_shortcode() </code> function call, and add it to your template, wrapped in an appropriate conditional tag, such as <code> in_category() </code> , e.g.: <code> if ( in_category( $cat ) ) ...
hard code shortcode only on specific category
wordpress
I'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts. From the documentation i gather this should work: <code> query_posts( array('post_type' =&gt; array('post', 'product') ) ); while (have_posts()) : the_post(); the_title(); the_excerpt(); endwhile; <...
almost! when doing it outside of the loop, you have to reset the query as in: <code> wp_reset_query(); </code>
Query for multiple post types does not work
wordpress
I have a custom post type (CPT) called <code> property </code> . I have registered a featured property <code> metabox </code> for it as explained in this question "stackexchange-url ("How do I create a featured post within a custom post type?")". So a featured property has got <code> meta_key='property_featured' </code...
<code> &lt;?php // query posts $query_property = query_posts( array( 'orderby' =&gt; 'date meta_value' // orderby date AND meta value ) ); // First loop $query_feat = $query_string.'&amp;meta_value=on&amp;meta_key=property_featured'; // Offset for second loop $query_all = $query_string.'&amp;offset=3&amp;meta_key=prope...
Display all custom post type posts and order them by an optional meta_key
wordpress
I looked 2 days now but I couldn't figure out how this is done: I created a new page in wordpress. This is easy. Then I see, that I can put content into the page. This is easy too. But how can I edit the page and add let's say the googlemaps api to it. I know there is a plugin but for some technical reasons I need to u...
Your best bet is to create a new "physical page" and save it in your theme root folder as a template called something suchlike tpl_aufwind.php like this: <code> &lt;?php /* * Template Name: Aufwind * * */ ?&gt; </code> you will need that code above at the very top of the tpl_aufwind.php so that it shows up in wp-admin ...
After creating a new page, filling the page with structure
wordpress
I understand its advantage for something which will be released in public, but does it do any good for a developer by saving efforts as the code evolves over time? Like right now, I am hardcoding the table name in my queries, what if I was to change the name or something?
The purpose of <code> dbDelta() </code> is both to create and update tables. If you don't need updates then you can skip it. For keeping track of name you can simply follow WP convention and save name of your table in field of <code> $wpdb </code> object. Also note that you should consider there is possibility of code ...
Advantages of dbDelta
wordpress
I just installed WordPress 3.1.2, I got `Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /works/web/elements/wp-includes/functions.php on line 3303 I also got an error about Cannot open stream or something about <code> wp-cron.php?doing-cron </co...
it sounds like even though its a fresh install of WP 3.1.2 that you are also using an existing theme that is using a deprecated function (you havent said so but im presuming), if so paste this into your themes functions.php file (if your theme doesnt have one just create one and save it in your themes root folder).. <c...
Getting Warnings & Notices from Fresh WordPress 3.1.2 install
wordpress
Running Wordpress 3.1.2 (newly updated, installed as 3.0 about a year ago) with subdomain multisite &amp; using the Sunrise domain mapping plugin. The frontend is fast, the backend (wp-admin) is very slow on the network admin site (www.example.com/wp-admin) but runs at "normal speed" on one of the subdomain backends (f...
I ended up enabling WP_DEBUG and found an error - something about <code> fsockopen() </code> not being able to connect to my host (I didn't write it down and now can't reproduce it) - and found that it was a DNS issue;- my subdomain (foo.example.com) was resolving to the correct IP (10.0.0.1) but the primary domain was...
wp-admin slow in multisite
wordpress
I'm looking for a plugin that could help me managing more precisely medias. I'd like to be able to manage folders and sub-folders. I found out the ImageManager plugin but it's kind of outdated (http://soderlind.no/archives/2006/01/03/imagemanager-20/) so if anyone can help ;) PS : working on WP 3.1.1
You might give NextGEN Gallery Plugin a try. While not specifically intended for sub-folder management of media, the end result is the same, since images added to galleries are organized by folder.
Managing media by folder
wordpress
I have this very basic scheme to build my first plugin, but now I have one problem: when I put a hook to add_action on point 1 works, but i need to get the color from shortcode function, so, when i put the code at point 2 don't works. <code> class myclass { public function init() { global $shortcode_tags; add_shortcode...
The main problem is you are using static callbacks while you should be passing on the object so you have access to your class properties. You can fire off the initialization like this: <code> class Myclass { public function __construct() { // Object method call, instead of a static one add_action('init', array($this, '...
plugin development: problem with functions
wordpress
In the latest version of WP it's gone. Why?
It seems that it still exists, you just have to enable showing it, with screen options http://theandystratton.com/2011/wordpress-3-1-admin-bar-and-i-cant-see-custom-fields
Where did the Add New Custom Field go?
wordpress
I am developing a plugin. I want to know difference between <code> get_bloginfo('url'); </code> and <code> get_site_url(); </code> I got same output, then what's the difference?
<code> get_bloginfo('url') </code> calls <code> home_url() </code> calls <code> get_home_url() </code> reads option <code> home </code> <code> get_bloginfo('wpurl') </code> calls <code> site_url() </code> calls <code> get_site_url() </code> reads option <code> siteurl </code> <code> get_bloginfo('siteurl') </code> and ...
What is difference between get_bloginfo('url') and get_site_url()?
wordpress
I've read several examples of how to do this but I still can't get it to work - each time I use get_posts() it seems to only keep and display the first set of results. loop.php <code> function home_index() { global $post; echo '&lt;ul&gt;'; $args = array( 'numberposts' =&gt; 3, 'offset' =&gt; 0, 'orderby' =&gt; 'post_d...
So I finally figured out 2 ways of doing it. The first way is... <code> global $wp_query; $args = array( array( 'numberposts' =&gt; 3, 'offset' =&gt; 0, 'orderby' =&gt; 'post_date', 'order' =&gt; 'DESC', 'post_type' =&gt; 'gp_news', 'post_status' =&gt; 'publish', 'meta_key' =&gt; '_thumbnail_id', 'meta_value' =&gt; 1, ...
Displaying multiple post types on home page
wordpress
Is there any free starter theme to make mobile websites using WordPress?
Yes, there are a few - did you search for them? Here are the top results from Google: WPTouch Carrington Mobile WordPress Mobile Pack
Free starter theme to make mobile websites?
wordpress
I would like to expand only the active part of the sidebar menu and hide the parts which have nothing to do with the actual selection. Just like how its done on every Explorer like file manager, or how it is with accordion menus. In the default TwentyTen theme, this is the class definition for the active submenu: <code...
I use just such a menu in my Oenology Theme. Feel free to use the sidebar menu CSS to suit your needs! Rather than try to post it all here, I'll just link to the Oenology GitHub repository . EDIT: Here's where the sidebar navigation menu style definitions start .
how to hide submenus for the not active pages
wordpress
I want to sync post edits on two sites. Test environment, not production. Single direction (site A to site B, but not backwards). Basically I edit post at my local test stack and same post (part of test content set) at remote server should be updated with identical copy of resulting content. I know that XML-RPC server ...
WordPress already has a XML-RPC client class implemented. It's in the same file as the server part: <code> class-IXR.php </code> located in <code> wp-includes </code> . The following code will generate a new post. You could wrap this in a function and attach it to the <code> save_post </code> / <code> update_post </cod...
WordPress as XML-RPC client?
wordpress
I'm still very novice at PHP so any help is greatly appreciated. Typically I have found the codex to be very helpful but it appears custom walkers may be outside its scope. I'd like to have thumbnails show in a custom nav menu which I have in a theme. From what I understand I need to create a custom walker to accomplis...
Add a semicolon ; after <code> get_the_post_thumbnail( $id ) </code> : <code> get_the_post_thumbnail( $id ); </code>
wordpress custom walker for thumbnails with custom menu
wordpress
the question is simple :) I am making a theme that i will use in lots of sites. So, i don't want to go all the site and ftp the files every time i fix a bug or do a theme upgrade. Is there any way i can make a update system like the plugins hosted in wordpress plugin directory. Looking forward to your answer. Thanks! S...
You can also hook into the core update routine. (I'm looking for tutorial links, but my Google-fu is failing me this morning.) EDIT: See if this tutorial helps. It explains how to implement automatic upgrades for private/commercial (i.e. non-repository-hosted) Plugins.
Making update notification functionality for my themes
wordpress
I noticed that huffingtonpost.com and some other websites are using tags instead of categories for blog structure. For example the last tag in this post (like every post) is redirecting to "technology news" section of the menu. Is it OK to use tags instead of categories in the wordpress menu? what's the advantage of do...
There is neither inherent advantage nor inherent disadvantage in using Tags versus Categories. Tags and categories are merely taxonomies , which are used to describe content. Tags and Categories don't actually provide site "structure", though their index pages can be added to custom Nav Menus. The primary difference be...
Using Tags Instead of Categories for site structure
wordpress
In buddypress when a user wants to delete their own account --> is possible to delete all their attachments entries and images uploaded using media? Note: Images are not attached to posts, because im not letting users create normal posts, they only can upload images using media. Thanks in advance.
As media uploads are simly files with no related data stored, you can't do that unless you extend the user data and save the file names, etc. as user meta data. Simple answer: No, it doesn't work.
Delete all user attachments
wordpress
On my site, I am working on categorizing pictures based on what is in them and am having trouble listing the categories that apply to the post. For instance: A post might include a picture of an ice cream cone with three flavors of ice cream. My category hierarchy for this post might be: Flavors -> Vanilla, Mint Chip, ...
Having two separate taxonomies may make sense for you in this case.
How do I list all child categories that apply to current post?
wordpress
Hi does anybody know where i can find a PayPal API tutorial that can help to point me in the right direction, What im needing is something that when payment is verified by paypal it bounces through some code to update_user_meta and also a few fields in a custom table in wp database. Information that i can find via goog...
Try working through the source code of a plugin such as PayPal Framework . From your question, the WP side is fairly trivial, but you should study general PayPal tutorials to understand the API, for example, here's the first search result from Google for PayPal API tutorial: Using PayPal's IPN with PHP Also some additi...
Paypal API and Wordpress
wordpress
With Disqus, can I allow the most 'liked' or 'favorited' comments to rise to the top, sort of like YouTube? If not, are there any other commenting systems that have this functionality built in?
You can use other plugins to do this too. Here are some I can think off: IntenseDebate Comment Rating Comments Vote I would suggest you use IntenseDebate by Automattic which means it will always be up-to-date and most compatible with your site.
disqus: comments that've been liked the most rise to the top...like youtube?
wordpress
This is probably a stupid question, but I am setting up a finnish Wordpress installation. The "custom fields" section in the "write post" section is gone; I gather it is hidden by default. That is a great step, but my finnish is a bit rusty, it's my first WP install, and I can't for the life of me find the switch to tu...
Per default some meta boxes are hidden. These boxes are stored in an array which you can find in <code> wp-admin/includes/template.php#get_hidden_meta_boxes() </code> . There is a filter, and therefore a chance for a plugin: <code> &lt;?php # -*- coding: utf-8 -*- /* Plugin Name: Enable Custom Fields per Default Versio...
How to activate "custom fields" section in WP3
wordpress
I'd like to modify the comments list (comments left by users) on WP site using BuddyPress. In comments.php I narrowed it down to the following code: <code> &lt;?php wp_list_comments( array( 'callback' =&gt; 'bp_dtheme_blog_comments' ) ); ?&gt; </code> Any clue where I can find bd_dtheme_blog_comments , and the best way...
Just search though your source code to find the function definition? It's in <code> plugins/buddypress/bp-themes/bp-default/functions.php </code> , and you can create your own version in your theme that should override the supplied one.
How to modify the comments list in WP & BuddyPress?
wordpress
I would like to remove blog posts from the home page if they belong to a certain category. How can I go about this in Buddypress (preferably without a plugin)?
If you mean filtering the home page activity stream by blog post category, it's not possible using any of the buit in BuddyPress template tags, functions or queries. I struggled with this same issue for months and finally gave up. If someone can prove me wrong I would love to hear the solution. If your not using the ac...
Filter Home Page Posts in Buddypress
wordpress
I have a function that redirects users to the login page (home) if they're trying to access any other page without being logged in, here's how it works: <code> function restrict_access_if_logged_out(){ if (!is_user_logged_in() &amp;&amp; !is_home()){ wp_redirect( get_option('home') ); } } add_action( 'wp', 'restrict_ac...
Thanks all, I kind of used a bit of what everyone recommended so in the end my code looks like this: <code> function restrict_access_if_logged_out(){ if (!is_user_logged_in() &amp;&amp; !is_home()){ wp_redirect( get_option('home') . '?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) ); } } add_a...
Redirect user to original url after login?
wordpress
In this website: http://alexchen.info/brianfunshine/ I have a navigation menu taken from the twentyten theme. I want to make some links clickeable and some not (some don't have to behave like a link). I have accomplished this with some CSS but it doesn't work in all browsers. The links are dinamically generated with: <...
Create a custom menu item in the admin panel with a dummy URL, foo.com or whatever. Add it to the menu, then delete the target URL and save. The menu item will be rendered without an href attribute and will be unclickable.
Making some links generated from the wp_nav-menu function unclickeable?
wordpress
hey guys, I have no idea how to solve the following problem. I'd love to have a page-template that lists all it's child-pages but with the content. e.g. Imagine I have a page called "WORK. And "Work" has childpages like "Work 01", "Work 02", "Work 03", etc. I don't just want "WORK" to list the names of the childpages a...
You would need to create a page template and query those pages directly. <code> $args = array( 'post_type' =&gt; 'page', 'post__in' =&gt; array(430,436,433), //The Page IDs you want to query 'order' =&gt; 'ASC' ); $page_query = new WP_Query($args); </code> If you wanted to do this automatically and get the child pages ...
Help with a custom page template - listing contents of childpages?
wordpress
I'm using the function echo time_ago() that displays the time like this: 5 days ago what's the best way to change it to 5d ago ? My research led me to human_time_diff() function located in "formatting.php" So I have tried directly editing the function located at /wp-includes/formatting.php but when I change "hours" to ...
There is no filter for output of that function. You can fork (copy/rename/edit) it or add wrapper that will replace strings in output like this: <code> function short_time_diff( $from, $to = '' ) { $diff = human_time_diff($from,$to); $replace = array( 'hour' =&gt; 'h', 'hours' =&gt; 'h', 'day' =&gt; 'd', 'days' =&gt; '...
Modify human_time_diff() to shorten "days" to "d" and "hours" to "h" etc
wordpress
Does anyone know how to publish your own bookmarklet in a blog like wordpress or blogger? All of them seem to format the bookmarklet removing the javascript or messing it up. E.g., pasting this in wordpress blog: &lt;a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g> f.fn.jquery||h(f)){c=a.createElement...
Create a clickable link on http://jsfiddle.net/ and link to it.
Your own Bookmarklet in a blog
wordpress
Hey guys, When adding an image to a page or post wordpress is automatically adding a paragraph tag as parent holding the image. since there is no parent selector in CSS I'd love to find a solution to apply a specific classname to those paragraphs holding an actual image. Any idea if I can use add_filter() to apply a cl...
You could use jQuery if you don't mind to rely on JavaScript for adding the class. <code> $(document).ready(function() { $('p:has(img)').addClass('image'); }); </code> Update: the <code> .has() </code> method is probably faster, see this jsperf.com test . <code> $(document).ready(function() { $('p').has('img').addClass...
Apply class to every paragraph that holds image?
wordpress
This is my query, it shows the posts that have meta_key as extra1 and meta_value as test <code> &lt;?php $customkey1 = 'extra1'; ?&gt; &lt;?php $customvalue1 = 'test'; ?&gt; &lt;?php query_posts('meta_key=' . $customkey1 . '&amp;meta_value=' . $customvalue1); ?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) ...
If you are using WP 3.1, I would recommend using the <code> meta_query </code> parameter with the WP_Query class. <code> $args = array( 'meta_query' =&gt; array( array( 'key' =&gt; $customkey1, 'value' =&gt; $customvalue1, 'compare' =&gt; '=' ), array( 'key' =&gt; $customkey2, 'value' =&gt; $customvalue2, 'compare' =&g...
How can I combine this php statement to get the results of multiple variable inputs?
wordpress
Preamble I'm finding myself building more and more WP sites "from scratch" as it were (ie: ignoring any theme designs out there and just creating a design wireframe purely on the needs of the client. Then I go out and either shop around a theme that has the right basic structure, or I start with TwentyTen and fork a ch...
Bare bone themes are great, personally I prefer them over frameworks. I have noticed that 'liking' one over another comes down to how it feels, so I would suggest trying several out until you find one. For instance a lot people like WordPress boilerplate but I could not get the hang of it. My current favorite is Handcr...
Opinions and recommendations on the best barebones base theme
wordpress
Hey everyone. I'm not sure if what I'm experiencing is a result of a bug (due to the recent upgrade to 3.1.2) or poor coding. Ever since i upgraded to version 3.1.2 ive been experiencing a problem with two loops on my index page. Here's what I've got for my index page <code> &lt;?php if ( ! is_paged() &amp;&amp; is_fro...
I tried reverting back to the older version 3.0.x, but the problem remained the same. The answer can be found here: stackexchange-url ("stackexchange-url
Wordpress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
wordpress
I'm working on a script that will drop articles directly into the wordpress database, using wp_insert_posts(). However, I have networking enabled and the wp_insert_post() reference page has no documentation relating to using wp_insert_post() to upload to a specific site on the network. How can I do this with wp_insert_...
When using function like <code> wp_insert_post() </code> It will work on the currently active blog, meaning that if you are on a blog in your network with blog_id of 2 the the post you insert using <code> wp_insert_post() </code> will be inserted to that blog. Now if you want to insert the post to a specific blog you c...
Using wp_insert_post() with Networking enabled
wordpress
im trying to implement uploading via a meta box without using the media manager, but i want it to add as a post attachment. im currently doing it just uploading and saving to the server. <code> &lt;?php define("THUMB_DIR", WP_CONTENT_DIR . '/plugins/meta-upload/thumbs/'); define("THUMB_URL", WP_CONTENT_URL . '/plugins/...
You may want to take a look at Steve Taylors plugin and his approach here Dominik "ocean90" Schilling - the author of the (new in 3.5) media library, has a GitHub repository where he shows off some demos. In short, you might not be able to implement a drag&amp;drop style media uploader in a meta box with his tutorials,...
upload image in a meta box
wordpress
DO you use links in your wordpress and why? Isn't it much easier to use you browser's bookmarks? I don't get the idea of having links at all! Please enlight me!
Links are not supposed to be bookmarks, they are more of a convenient way to integrate links in site. The feature is kinda underused (I think blogrolls it single most common usage for it and seems to start to fade) and so under-appreciated. Really there are plenty of stuff you can do with links, for example I wrote a p...
Do you use links?
wordpress
I'm using Wordpress 3.1.2, and have three blogs in a wordpress network. I would like to change some settings for a specific plugin, but have the changes applied to all the blogs on the network. I can't change plugin settings on the "Network Admin", and instead have to do it on the "Site Admin" page for each individual ...
It really depends on the plugin developer now on how they incorporate settings the other option is to try and put it inside the /wp-content/mu-plugins but im not sure if that will allow you to have only a master setting you could also try hard coding it in the plugin files. What plugin is it i might be able to better h...
Network-Wide Plugin Settings Management
wordpress
I'd like to pull data from a mySQL database and put it in some tables in a WP page. I'm using WP 3.1.1. Imagine that I've got a table of sales figures that I want to pull from a mySQL database and then display them in a table on a WordPress page. I know just enough php to make a db connection, pull the data, and echo i...
Yes, you can store your data in your own tables in WordPress database. There are few things that you need to take care of: Make sure your data can't be really represented using the built-in Wordpress content types. Prefix your tables with WordPress Prefix + your prefix. WordPress table prefix is $wpdb-> prefix. Use the...
Using Dynamic Data Pulled from a MySQL Table in a WordPress Page
wordpress
I am trying to using jquery ui tabs with ajax calls to run a function. Here is the code i am using: <code> function ajax_load_user_feed(){ if(isset($_GET['type'])) $type = $_GET['type']; if(isset($_GET['userid'])) $userid = $_GET['userid']; if(!$type &amp;&amp; !$userid){ $type = 'error'; show_feed($type); die(); } els...
Your ajax hook <code> add_action('wp_ajax_load_user_feed', 'ajax_load_user_feed'); </code> is for logged in users only, if you want none logged in users (guests or visitors) then add: <code> add_action('wp_ajax_nopriv_load_user_feed', 'ajax_load_user_feed'); </code> and you should be fine.
How to make ajax call in wordpress in right way?
wordpress
I've installed Easy Post Types created a custom post type: Attractions created an Attraction: (joes-cafe) created a category set: attraction-type (cafe) copied single.php to single-attractions.php added the category: cafe to wp-navigation-menu But when I visit the menu item, I get a 404, when i search for the cafe by n...
The rewrite rules need to be flushed when you add a custom post type, this can be done by visiting the permalinks admin page.
Easy-Post-Type is visible in search, but 404 when clicked
wordpress
I have a problem when i want to upgrade Wordpress or install plugin via the Admin. It's say that I don't have the permission to write. but I can upload images and other things... but i cannot install plugin and/or update plugin/WordPress. I know that my user server is not the file owner but is part of the group owner.
I find the answer to my question <code> define('FS_METHOD', 'direct'); </code> core.trac.wordpress.org/ticket/10205 thanks @xLRDxREVENGEx for the tip for upgrading manually but when you make a theme framework and you want to update you parent theme framework in the admin you need to apply the <code> define('FS_METHOD',...
Upgrading WordPress (File permission group owner)
wordpress
I've set 2 new roles for my site using the "Members" plugin - "sellers" and "buyers". Each role should have its own registration page and login. A visitor can register as both a buyer and a seller but he can only be logged in as one of them. So, if a visitor has logged in as a seller and then goes to the buyer page he'...
Creating two separate registration for different roles is easy: <code> //create a hidden field for role add_action('register_form','add_hidden_role_field'); function add_hidden_role_field(){ if (isset($_GET['role'])){ echo '&lt;input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="...
Separate registration and login for different roles
wordpress
I'm looking for a slider plugin that allow me to insert additional buttons in a slider, not the next and prev neither numbers, I mean buttons to redirect users to a different page, etc... I would appreciate your info! Regards
You should look for sliders that allow you to insert HTML content inside your slides. jQuery Cycle is a good example, look at non-image content: http://jquery.malsup.com/cycle/int2.html
Sliders with buttons
wordpress
hey guys, it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using <code> &lt;?php echo date("H:i"); ?&gt; </code> in my theme. The time that's put is 2h earlier. e.g. if it's actually 16:00 o'clock the date generated with date() is 14:00. I don't know why that happens? I...
This could probably make exquisite debugging session, but taking in account it's Friday evening - just use <code> date_i18n() </code> instead and let WordPress deal with a huge mess that time/date issues usually are.
wrong php date()?
wordpress
I'm trying to add a stylesheet to the options page for my plugin - code looks like this: <code> add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' ); function rps_paypal_add_css() { wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) ); } add_action( 'admin_menu', 'rps_myplugi...
the call to add_options_page will return the string literal to use for your RSS, so it should look something like this: <code> $page = add_options_page( ... ); add_action( 'admin_print_styles-' . $page, 'rps_paypal_add_css' ); </code> More info here: http://codex.wordpress.org/Function_Reference/wp_enqueue_style
wp_enqueue_style for plugin options page
wordpress
Well my question is quite simple, I would like to populate a field with the value of a variable that have been passed via a $_GET Request. thanks
Take a look at Contact Form 7 Dynamic Text Extension
Wordpress Contact Form 7: populate the value of a field dynamically with PHP
wordpress
So I have this code: <code> &lt;?php wp_list_categories(array( 'show_option_all' =&gt; 'All Categories', 'orderby' =&gt; 'ID', 'order' =&gt; 'DESC', 'use_desc_for_title' =&gt; 0, 'child_of' =&gt; 0, 'exclude' =&gt; '', 'exclude_tree' =&gt; '', 'include' =&gt; '', 'hierarchical' =&gt; 1, 'title_li' =&gt; NULL, 'show_opt...
Isaac, I guess this derived from the <code> wp_dropdown_categories() </code> function which is supposed to work like a filter on a page -- display posts from a certain category or display posts from all categories. So <code> wp_list_categories </code> does the same but in a list of links instead of a dropdown menu, so ...
Does "show_option_all" in wp_list_categories do anything?
wordpress
I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I'd like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is: <code> 1. Movies 1.1 General 1.2 Westerns 1.3 Animated 2. Musi...
Using WordPress custom nav menus create a menu and add the "General" page 2 times. The first as the parent and the second as the first child then add the rest of the pages as childs under the first General. Change the title in the first general to movies then on the front end when a user clicks movies they will got to ...
Directing a page to a default subpage
wordpress
When uploading images via the media manager there are a couple of set sizes available such as thumb, medium and large. I do know how to add additional sizes, but I have yet to get it to insert an image with width='x%'. the concept is that i am building an adaptive theme and I never want the inserted image to be larger ...
I guess what you're looking for is the <code> $content_width </code> global that would basically limit the width of your images, used in functions.php. Some more info here: http://mainstreetopen.com/wordpress-26-and-full-width-images/
Set Image width='x%' (percentage width not pixel width) when inserted via the media manager?
wordpress
I'm studying TwentyTen, under the assumption that it contains the best practices for writing themes and modifying them using child themes. I'm noticing what looks like a really redundant practice, which is to overload not the base template file (eg: attachment.php) but instead to overload the template-part file (eg: lo...
TwentyTen was designed to help understand the WordPress theming system and that is why it has more lines of comments then actual code. So looking at TwentyTen you need to understand that they tried to include every file in the Template Hierarchy (eg: attachment.php, single.php, page.php) and every template tag there is...
TwentyTen: Overloading template.php files vs. get_template_part
wordpress
I'm about to embark on creating a new WP that, at the core, will rely on a custom post type. I'm building this plugin for a client, but plan to make it flexible enough to release in the future. My client has a specific need for the plugin and I ultimately want it to be flexible enough to meet the needs of many users. A...
I would not give them control over the actual name of the post type. What if they rename it to revision or attachment? Big time site wreckage potential there. I'd say stick with the more "trivial" things; basically, only those things that don't go into the database: labels, rewrite settings (although that could be pote...
Building plugin with changeable custom post type values...advice needed
wordpress
I'm creating a parent theme and several child themes. But how can I prevent the parent theme from ever being used?
Not using the current system. In order to serve as a valid Template for a Child Theme, the Parent Theme must exist, and be a valid Theme. That's because the Parent Theme's template files must be accessible via <code> locate_template() </code> , in order for the Child-Parent fallback to work properly. Note: if this core...
Child themes: disabling the parent
wordpress
With the help of the internet and you lot, I have been stumbling about to create a worpress site here . So at this stage, its not exactly a default install. - Im running the boldy theme from Site5. - Have made some tweaks to the underlying PHP, but nothing that I can think that would cause this issue. Issue : Slugs set...
Here's what I think is causing the problem: <code> &lt;?php query_posts($query_string . '&amp;cat=-98, 101, 102'); ?&gt; </code> should be: <code> &lt;?php query_posts($query_string . '&amp;cat=-98,-101,-102'); ?&gt; </code> The way it is now, it's telling WordPress re-run the old query, but give me nothing from catego...
Category Slugs = 404s?
wordpress
I normally work ahead of schedule and sometimes need to contact people when a certain post reaches publication. Is there any plugin that will do this? It would need to be customisable for each post as most posts I don't need this reminder, and for the ones where I do need it I would need to write something different ea...
Would you consider using a specific category or tag to use on posts that require notification? If so, you could use Peter's Collaboration E-mails plugin which can automatically notify you (or other specific users) when a post is set to Pending, Scheduled, or Published. In the plugin settings, you can define specific ca...
Notification when certain posts are published
wordpress
I have a bunch of widgets that I load from php files, like so: I added a PHP CODE widget and inside wrote: <code> &lt;?php include '/wp-content/themes/myTheme/parts/block1.php'; ?&gt; </code> This worked well on my localhost, but for some reason it stopped working when I uploaded that website online (and switched the h...
The correct way to load a PHP file in the theme directory is to use the locate_template function. <code> &lt;?php locate_template(array('parts/block1.php'),true,false); ?&gt; </code> The true makes it automatically require it. The false makes it not require_once it.
Including PHP files doesn't work outside of Localhost
wordpress
I'm working on a new WP site. The WordPress installation has already been done on a live server by the ISP and now I need to skin it. I am wondering if I should bring the site down to my local machine and work off that. Having to upload constantly would be rather annoying. I'm a little concerned that I will screw soemt...
If the other answers make sense I apologise for how patronising my answer must sound - but if they don't make sense perhaps my N00B style answer will :) You can't mess up the installation of wordpress on your live server if you are simply developing a theme on the localhost installation (a skin is known as a theme when...
Installing WordPress locally
wordpress
I have a function like the following: <code> &lt;?php echo my_custom_function( array( 'category_url'=&gt;'My Special Category' ) ); ?&gt; </code> It pulls data from the "My Special Category" and displays it. I want to put a conditional statement around it that says if, and only if, that category has stuff to display, t...
The following function shows you some "best practice" example ;) It includes error handling, checking for emtpy array values, parsing input args with defaults, cares about if you want to echo the result, etc. You even got a filter for your child themes defaults. :) The function in your functions.php file: <code> functi...
If function exists, and array is met, echo function?
wordpress
I am using custom post types "listings" and I have a category called "type" and 3 sub cats, "available", "pending", "sold". I want to display an image/icon on each post in the loop (not the single-listings.php) but the archive view, that corresponds to it's category. Take a look at woothemes' Estate for an example. The...
You can use the conditional with <code> in_category </code> . http://codex.wordpress.org/Function_Reference/in_category For example after your loop: <code> &lt;?php if (in_category('type')) { ?&gt; &lt;img src="&lt;?php echo get_stylesheet_directory_uri();?&gt;/images/custom.gif" alt="" class="customicons"/&gt; </code>
Category Icon on custom post type
wordpress
All of my posts in one category (i.e. Location) have two custom fields: latitude and longitude. I would like to return an XML or JSON of all those posts (title, latitude, longitude) for use as Google Maps markers. I can't simply call out to a stand-alone php file to return my data as I would like to access my data thro...
The best solution is to create a custom XML page template in the exact format you need. If you look at the code below taken from the WordPress XML exporter you can see that the data it returns contains the normal stuff we see in a typical WordPress loop. <code> echo '&lt;?xml version="1.0" encoding="' . get_bloginfo('c...
Return XML of Post Metadata
wordpress
When the_content print attachment images (attachment template) it automatocally displays the picture. Is there a hook to specify the width and height of the image displayed?
I believe this is what your looking for. The complete code can be found in twentyten's loop-attachment.php template. Look for the <code> &lt;p class="attachment"&gt; </code> tag. There are two filters there. One for width and the other for height (currently set to 900px for both). <code> &lt;?php if ( wp_attachment_is_...
How to specify width and height in the_content for image attachments
wordpress