question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I love WordPress, but I also love GitHub. Would love to know if there is a seamless solution to using both SVN and GitHub for plugin development?
The wordpress plugin repo does not have any API as far as I can tell for push and pull hooks from a 3rd party service like github. Right now the solutions are hacky at best and require you to use git as a middle man (on your computer) and also deal with SVN's use of tags/trunk/branch which git doesn't like very much. I...
Is there a seamless solution for submitting plugins to wordpress.org SVN and GitHub?
wordpress
I was looking for a particular page today and got search results that surprised me. Here's what happened: start on Dashboard-> Pages-> All Pages search "standard" URL= http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=page&action=-1&m=0&paged=1&action2=-1 get list of some...
It's hard to say what's actually causing the issue, but it isn't WordPress. Try deactivating all themes and plug-ins, a reactivating them one by one until the problem occurs to isolate the plug-in/theme responsible. You'll have to contact the developer and they may look into it for you.
admin search of pages returns custom post types
wordpress
By adding a new committer and removing the original committer can I effectively change ownership of plugin? I would like to transfer a plugin to a new wordpress.org profile. I am the author.
It will effectively change the ownership, though it will still show up in your profile if your old username is listed as a contributor, and may still show up in your profile if your old username was the creator of the plugin. To fix the second part, email plugins@wordpress.org and Otto42 or I can re-assign it.
Can I change ownership of my plugin?
wordpress
I'm just wondering why wordpress doesn't send confirmation mail every time user change his/her email address. How do we know that email address is not fake or mistyped? So can anyone give me some snippet to implement this function? Update: Here is the idea. user changes his/her mail We send confirmation email. If the u...
Like SickHippie posted this functionality is native to WordPress but only for a multisite setup so here is the two functions you need to get this to work on a single site setup which are mostly code one for one from the core <code> /wp-admin/user-edit.php file </code> <code> function custom_send_confirmation_on_profile...
Confirmation required on email change
wordpress
I am managing a couple of WordPress sites, all hosted on the same VPS, and the client would like the homepage blogroll of <code> Site A </code> , that the own, to appear on <code> Site B </code> that the also own with the same Author attribution, preferably to link to the originating sites author as opposed to a duped ...
You have a couple of options here, but first let me advise you away from querying the database directly. If your sites are that closely related, then they should be in a Multisite network ... RSS On Site B, fetch the RSS of Site A and display the posts and author attributions there. You can find any number of RSS plugi...
Show Blogroll of another WordPress site
wordpress
I develop themes, lots of them. I am given a PSD, code up the HTML/CSS, slap the code into Wordpress, and make corrections as they get QC'd. Once live, clients can edit blog posts like normal or upload photos using a custom plugin. Sometimes I have to make changes to the theme or to the page/post content, which means I...
First of all, you need to recognize that there are two workflows here: yours and your client. Your Workflow Receive PSD Code HTML/CSS Code WordPress template Deploy theme to live WordPress site Their Workflow Devise required changes and email you Write posts Upload photos The Issue Implementing version control here has...
How do I add version control to my workflow?
wordpress
I´m developing a theme that include plugins. One of this plugins is a contact form. And this plugin have an asociate code to validate input data. Because I don´t know in what pages contact form was been added... I want to find a right way to detect if a plugin is included in a current page. Sample: page.php <code> &lt;...
If I understand correctly you want to include a php file that validates the form input, but only when you need to actually validate something? In this case, you don't need to check if the contact form exists on some page - you just need to check if the form data has been posted. All you need to do is add a hidden field...
Detect if a plugin was included in a certain page
wordpress
I copied TwentyEleven and used all its resources to start, I've done all the steps, added my own widgets, menus, css, js and all but I'm stuck with this issue: I set the front page to be static and set a page for it (it has content in it), also set a blank page for the blog posts. The theme just shows the pages as blan...
First of all Create Template and Assign Template to Static page to which u have to display as a home page. Example of template: <code> &lt;?php /** * Template Name: Home Page Template * */ get_header(); ?&gt; &lt;div class="mid-part cm-fl"&gt; &lt;div id="container"&gt; &lt;div id="content" role="main"&gt; &lt;div clas...
My new Wordpress theme based on the TwentyEleven theme doesn't display the front page OR the blog page
wordpress
I've been working on modifying the Thesography plugin to include the Google Maps API. So far I've had success doing so. I'm looking to take this one step further and have 1 large Google Map that would display all of my images on 1 map. Then when you hover over a marker, an image thumbnail comes up with the post title. ...
Trying using <code> WP_Query() </code> using the <code> meta_query </code> arguments . Something like this: <code> &lt;?php $geotag_post_query_args = array( 'meta_key' =&gt; 'latlng_readable' ); $geotagged_posts = new WP_Query( $geotag_post_query_args ); ?&gt; </code> Now, <code> $geotagged_posts </code> is a query obj...
How to query posts with certain custom meta data, and output Post data
wordpress
in my wordpress plugin file I have this code that includes a javascript <code> function javascript_file-exmp() { $src = plugins_url('test.js', __FILE__); wp_register_script( 'links', $src ); wp_enqueue_script( 'links' ); wp_enqueue_script( 'jquery' ); } add_action('init','javascript_file-exmp'); </code> the test.js fil...
First you should use the wp_enqueue_scripts to load your scripts. <code> add_action( 'wp_enqueue_scripts' , 'javascript_file-exmp' ); </code> Second, be sure to both register and then enqueue your script Register: <code> wp_register_script( 'links', plugins_url( 'test.js', __FILE__ ), array( 'jquery' ), '1.0', true ); ...
how would I include a js file with tags into wordpress?
wordpress
I'm using Settings API and wondering if there's any way of editing default output of add_settings_field() function? <code> add_settings_field('the_field', 'bar', 'foo', 'page', 'section'); function foo() { echo 'foo'; } </code> Outputs: <code> &lt;table class="form-table"&gt; &lt;tr valign="top"&gt; &lt;th scope="row"&...
If you look at <code> do_settings_fields() </code> (line 1125, <code> /wp-admin/includes/template.php </code> ), you can see that the table information is hardcoded into the the settings API. If you wish to not use the table, you will need to develop your own settings functions.
Settings API - changing add_settings_field() output?
wordpress
I have created a plugin which will create a table in database on plugin activation. When I enabled the plugin and check the database, there was no new table which I want to create. Here is my plugin file code. <code> &lt;?php /* Plugin Name: wp_course_management Description: Wordpress plugin for course management for a...
Instead of this code <code> $sql = $wpdb-&gt;prepare( "CREATE TABLE %s ( id mediumint(9) NOT NULL AUTO_INCREMENT, time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, name tinytext NOT NULL, text text NOT NULL, url VARCHAR(55) DEFAULT '' NOT NULL, UNIQUE KEY id (id) );", $table_name ); </code> I used this. <code> $sql...
My custom plugin did not create db tables in database
wordpress
I just installed the MathJax Extension for Wordpress because I did not really like the way the math were rendered with the <code> [latex] </code> tags provided with the JetPack. If I use the classic <code> $$ </code> , the blog renders the equation using MathJax. However, if I keep using <code> [latex] </code> the JetP...
Remove Jetpack’s shortcode handler: <code> remove_shortcode( 'latex', 'latex_shortcode' ); </code> I don’t know when exactly the shortcode is registered, you have to find the best execution point (action) to remove it.
Compatibility of MathJax extension and JetPack
wordpress
Is there an easy way to include an upload box to your settings page? I am building an Open Graph options page and I like users to upload a standard image directly from that page.
WordPress provides a convenient function for just this purpose: <code> wp_handle_upload() </code> . Assuming that you already have the appropriate file form field in your settings page, and that you're using <code> register_setting() </code> for your options, and therefore already have an options validation callback, s...
How can you upload an image from within a settings page?
wordpress
I have a plugin that creates tables when activated or when a new blog is added to a network. When a blog is deleted I would like to be able to remove those tables for that blog. Is there a hook available to do this? I imagine it would be something similar to wpmu_new_blog, but I can't find an equivalent for deleting.
The function <code> wpmu_delete_blog </code> in <code> /wp-admin/includes/ms.php </code> has an action hook called <code> delete_blog </code> . This hook passes the variable of <code> $blog_id </code> You could try plugging into that hook, although it is executed right at the beginning of the function.
Is it possible to run plugin code when a multisite blog is deleted?
wordpress
I am working on a site that is using posts as a way to manage glossary articles like the example site below. I would like to find a way to display articles alphabetically and grouped by a selected letter (such as the letter 'F' in the example). I would like the process to be reasonably automatic. Example of desired out...
once up a time i did a client project where i had to have archives by first letter. thinking back i'm wondering if shouldn't have just created a hidden taxonomy and then saved the first letter as a term in that taxonomy. anyway, here's what i actually did: <code> /* * Function Create Array of Letters that have post tit...
How to build a directory with indexes in Wordpress
wordpress
How do I go about adding a simple button to tinymce on the default editor area of my new Custom Post Type? I'd like the button, when clicked, to ask for a text value. The script should then <code> lowercase </code> the input and replace spaces with hyphens, and insert <code> [glossary=value-entered] </code> into the ed...
Check out this tutorial on Pro Blog Design: http://www.problogdesign.com/wordpress/user-friendly-short-codes-with-tinymce/
Add a button to tinyMCE editor on Custom Post Type
wordpress
When I use <code> the_permalink </code> or <code> get_the_permalink </code> in a draft or scheduled post, the URL provided is not the "final" permalink—it is the unpretty <code> ?p=xxxxx </code> version. How can I get the final, "clean" permalink to show up in a draft or scheduled post? I could do something involving <...
This is a little "hacky", but when you call <code> get_permalink </code> and you need the permalink from a draft, provide a clone of your post object with the details filled in: <code> global $post; if (in_array($post-&gt;post_status, array('draft', 'pending', 'auto-draft'))) { $my_post = clone $post; $my_post-&gt;post...
How to get the clean permalink in a draft?
wordpress
As far as I understand (from the get_template_part codex ) <code> get_template_part </code> is just a wrapper round the PHP require function. So if I have a variable that I have create in a page template file e.g. <code> $message </code> , I would have assumed you could directly use that variable in the template part S...
D'oh, it just needs a 'global' as its inside a function. messages.php: <code> &lt;?php global $message; echo $message; ?&gt; </code>
Variable use in get_template_part
wordpress
I am having trouble running query_posts when my page loads for the first time, i.e Session is empty. When the page loads for the first time and the SESSION is empty, the following code runs: <code> &lt;?php $id = 106; if ((empty($_SESSION['r1']))){ echo "This Line Prints"; query_posts("cat=-.'$id'&amp;".$query_string);...
<code> if ( empty($_SESSION['r1']) ) { global $query_string; query_posts($query_string . "&amp;cat=-" . $id); } </code> This should work, depending on $id is set.
Run query_posts if SESSION is empty?
wordpress
I don't want to show the permalink if the user is subscriber. Can anyone help me to achieve that? PS: I'm talking about the permalink which appears <code> below title </code> while creating new post. PPS: I modified the rules for subscriber. They can able to submit the post for review
<code> function hide_slug_box() { global $post; global $pagenow; if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php') { echo "&lt;script type='text/javascript'&gt; jQuery(document).ready(function($) { jQuery('#edit-slug-box').hide(); }); &lt;/script&gt; "; } } add_action( 'admin_head', 'hide_slug...
hiding permalink in admin if the user is subscriber
wordpress
Does having BuddyPress installed on a Multisite setup mean that users in each of the different sites can interact or view the actions or content of users on other sites in the network?
John James Jacoby, Lead developer of BuddyPress said this. BuddyPress sits on top of an entire WordPress installation, regardless of configuration. That means on single-site, multi-site, or multi-network installations, BuddyPress only has 1 set of data tables. As a result, you only have 1 set of Groups, Activity, Priva...
BuddyPress on Multisite
wordpress
I needed to replace the <code> #site-title </code> text with an image and I found a great blog post explaining this: http://bentcorner.com/replacing-wordpress-twenty-eleven-site-title-with-an-image/ But it appears that the image to be placed in <code> background: url(/header.png) #fff no-repeat; </code> must always lie...
The / in header.png makes it look in the root directory. Try just doing <code> background: url(header.png) #fff no-repeat; </code>
When replacing #site-title with an image - why must it be located in root?
wordpress
I am trying to figure out how to have a user bio in the user profile using BuddyPress. For example, on this page http://buddypress.org/community/members/johnjamesjacoby/activity/just-me/ where it says "I help lead the BuddyPress and bbPress projects. I also like puppies, potato chips, and a good nap." I'm assuming it's...
I ended up adding a User Bio Profile Field and then displayed it by inserting the following into member-header.php in the BuddyPress theme files: <code> &lt;?php if ( bp_get_profile_field_data( 'field=User Bio' ) ) : ?&gt; &lt;div class="user-bio"&gt;&lt;?php bp_profile_field_data( 'field=User Bio' );?&gt;&lt;/div&gt; ...
BuddyPress user bio in profile
wordpress
I have a Glossary CPT. Title, editor, slug and featured image. I would like to add a filter to Post content (and content of my other CPT "species") which looks through all of the content in each post and replaces any words found in the Glossary with a link to the glossary entry. For example... Glossary entry : test Pos...
This was a fun project. I think I could write an entire chapter in a book on this (in fact, I practically did below). Anyway, I messed around with a bunch of ways to do this, and here's the simplest way I came up with: <code> function add_glossary_links($content) { global $wpdb, $wordlist; if ( !$wordlist &amp;&amp; !$...
Most efficient way to search for values from CPT in Post content
wordpress
Is it possible to move the entire wp-content folder outside of the Web root? I need to prevent anyone to view any asset file (images, pdfs, movies etc) with a direct url to the file... Any ideas? Or could I do this safely with htaccess?
See Ben Word - How to Hide WordPress Summary: In the Roots Theme we’re taking several steps to help make it not so obvious that you’re using WordPress: Cleaning up the output of <code> wp_head </code> and removing the generator from RSS feeds Hiding <code> /wp-content/ </code> by rewriting static theme assets (CSS, JS,...
Moving wp-content outside of web root?
wordpress
I'm struggling with getting a few things in WP to redirect. I'm using a front-end profile / profile editor, and I'm also using a front-end login/register. Naturally I would like to redirect the standard wp-login.php URLS to specific ones. Mainly : <code> http://www.mysite.com/wp-login.php?action=lostpassword =&gt; http...
Ozh has a great tutorial about pretty login URLs, that you might find helpful - Pretty Login URL: a Simple Rewrite API Plugin Example
Rewrite wp-login.php URLS to static pages?
wordpress
I want to remove the entire section that says Save Draft, Preview and Status: Draft and Visibility: Public. I want to not show it. Its ok if it is still fuctional. Attached is the part I do not want to display. Can someone show me how to do it? Here is the area I want to not display: http://kind.s3.amazonaws.com/remove...
You can hide them using CSS. Add this to the theme's functions.php file, or add a plug-in header to the top of the file and zip it up to use as a plug-in: <code> &lt;?php add_action('admin_print_styles', 'remove_this_stuff'); function remove_this_stuff() { ?&gt; &lt;style&gt; #misc-publishing-actions, #minor-publishing...
Remove Save Draft & Preview Buttions.. and also Statius: Draft & Visibility: Public
wordpress
I need to find a way to list all categories - empty or not - in a hierarchial list - like wp_list_categories - also showing the slug, cat name and a link to edit in the admin. Here is what I have so far: <code> $args = array( 'orderby' =&gt; 'name', 'order' =&gt; 'ASC', 'hide_empty' =&gt; '0', ); $categories = get_cate...
output as unordered list: <code> &lt;?php hierarchical_category_tree( 0 ); // the function call; 0 for all categories; or cat ID function hierarchical_category_tree( $cat ) { // wpse-41548 // alchymyth // a hierarchical list of all categories // $next = get_categories('hide_empty=false&amp;orderby=name&amp;order=ASC&am...
get_categories hierarchical order like wp_list_categories - with name, slug & link to edit cat
wordpress
i’m using wp-ecommerce (getshopped) and WPML on a website, all pages display correctly when i use the default (/ugly…) permalink structure, but when i try to use the much desired permalink structure /%category%/%postname%/ something weird happens: product categories list page displays the homepage single category and s...
Apologies, I find this a little bit a non-issue as it states clearly everywhere that WPML works 100% when you use a permalinks structure of day and name (http://domain.com/2012/02/07/sample-post/). If this is something you cannot accept, then you's better come to terms with the fact that WPML most likely is not going t...
WP-e-commerce (getshopped) - Annoying permalink issue
wordpress
I have 7 meta fields for a custom post type in Wordpress. These 7 in particular are days of the week (Sunday thru Saturday) and have checkboxes for each. I've successfully gotten the checkbox to POST when the value is "On", however when I return to the edit page and try to deselect, the value stays the same in the data...
It appears the post meta is not being cleared for 'sunday' when the checkbox is unchecked. <code> If( isset($_POST['sunday']) ){ update_post_meta($post-&gt;ID, "sunday", $_POST["sunday"] ); }else{ delete_post_meta($post-&gt;ID, "sunday"); } return $post; </code> Or you can set the value to false <code> If( isset($_POST...
Custom Post type - how to get checkbox to update meta field to null
wordpress
I would like to create a child theme based on the twentyeleven theme. I understand how to create my own styles.css file to work for my child theme. I would also like to create my own custom <code> header.php index.php footer.php functions.php </code> files. My question is what information do I need to have placed in th...
style.css is the one and only required file in a child theme. It provides the information header by which WordPress recognizes the child theme, and it replaces the style.css of the parent. As with any WordPress theme, the information header must be at the top of the file, the only difference being that in a child theme...
How to properly create a child theme
wordpress
The title basically says it all. I know I can use the following to get posts from the <code> aside </code> post format: <code> $args = array( 'post_type'=&gt; 'post', 'post_status' =&gt; 'publish', 'order' =&gt; 'DESC', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'post_format', 'field' =&gt; 'slug', 'terms' =&gt; ...
You just need to set the <code> operator </code> parameter to <code> 'NOT IN' </code> ( see Codex on tax queries ). Untested, but for your purposes: <code> $args = array( 'post_type'=&gt; 'post', 'post_status' =&gt; 'publish', 'order' =&gt; 'DESC', 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'post_format', 'field'...
Exclude post format from get_posts
wordpress
I am looking for ideas or plugins that would allow me to have a backend area for clients to log into my site and access files specifically assigned to them. I provide video IT help files for clients which contain information specific to their setup and would also like to have the ability to offer or accept files from t...
Try Justin Tadlock's members plug-in . You can then create custom roles per user in the Users/Roles/Add New section of the WP-Admin Area. Once the role is created, you can add custom capabilities. I've never tried the email option you've mentioned, but it's possible. If you go this route I'll try to help you figure it ...
Information and Videos for Customers in the Backend
wordpress
How do I remove the link generated by the_tags? This is what I use today: <code> &lt;?php the_tags( '', '', '' ); ?&gt; </code> That results in the tags assigned to the post. But I want to remove the link. Any idea?
Use following code: <code> &lt;?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag-&gt;name . ' '; } } ?&gt; </code> More details: http://wpeden.com/tipsntuts/getting-list-of-tags-for-a-post/
Wordpress: Remove link in the_tags
wordpress
Hello, I have been stumped for a few days on a perfect way to display the posts using my custom post type (track) and the taxonomies ( genre, sub_genre). When a user goes to http://sitename.com/genre/ "sub_genre name" , i want all posts of that sub_genre to be categorized by those sub_genre taxonomies with content. ex....
What you are doing Your <code> foreach </code> is nested inside <code> while (have_posts()) : the_post(); </code> . This while loop, loops through each of your posts (in the genre 'hip_hop'). So for each post in the genre 'hip_hop', you find the post's taxonomy terms for the taxonomy 'sub_genre' (this is the contents o...
Taxonomy posts on Archive page
wordpress
I have been using the following function to enqueue some CSS to my theme. However, they are used in the admin area as well: <code> wp_enqueue_style(...) </code> I don't want them to be used in the admin area. Sadly I cannot find anything about that neither here nor on Google in combination with this function. The codex...
There are a couple of options. One is to wrap the enqueue in a check to see if it is the admin. <code> if(!is_admin()) wp_enqueue_style(....); </code> The other is wait to enqueue the style until template_redirect. <code> function my_enqueue_styles() { wp_enqueue_style(....); } add_action( 'template_redirect', 'my_enqu...
Exclude stylesheet from admin
wordpress
I'm using this code. <code> add_filter('meta-box-order_post','one_column_for_all'); function one_column_for_all($result, $option, $user){ $result['normal'] = 'postexcerpt,formatdiv,trackbacksdiv,tagsdiv-post_tag,categorydiv,postimagediv,postcustom,commentstatusdiv,slugdiv,authordiv,submitdiv'; $result['side'] = ''; $re...
Try something like this: <code> // First make all metaboxes have 'normal' context (note the absence of 'submitdiv') // If you know the ids of the metaboxes, you could add them here and skip the next function altogether add_filter('get_user_option_meta-box-order_post', 'one_column_for_all', 10, 1); function one_column_f...
1 column admin screen options - move submitdiv to bottom
wordpress
I am doing development and testing of a WordPress site on my local machine and have tweaked the WP settings accordingly using the GUI. Installation of WP on my host is easy however, I do not want to go through the GUI and setup everything from the beginning and would like to just import the settings from my local machi...
Follow the steps: Copy/Move all files to new location Export database from old mysql server and import data in new server (you can use phpmyadmin for that) Select wp_options table using phpmyadmin from new location. Edit 2 entry in option table with option name home and siteurl . set option value = new location url Log...
Importing WP settings to another host
wordpress
Below is the code I'm using to query multi-day events. The problem I'm having is that I can either sort by the start date (evstart_date) OR I can do a combined query against start date and end date (evend_date). But I cannot do both the combined query AND sort. The code below gets the query right (continues to display ...
I had this same problem until I realized you don't actually have to query by the event start date, only the end date. As long as the event's end date has not past it doesn't matter whether the start date is in the future or not. All you have to do is grab all the dates that have not ended yet then you can order them by...
Can't seem to do combined query AND sort?
wordpress
Jeditable is saving data to the file like: <code> $('.edit_area').editable('http://www.example.com/save.php', { type : 'textarea', cancel : 'Cancel', submit : 'OK', indicator : '&lt;img src="img/indicator.gif"&gt;', tooltip : 'Click to edit...' });` </code> How do I replace JQuery.ajax with admin-ajax.php? Do I just re...
I found a solution for my question. This plugin works with url formatted like: <code> $('.edit_area').editable('&lt;?php echo admin_url('admin-ajax.php'); ?&gt;?action=youraction', { type : 'textarea', cancel : 'Cancel', submit : 'OK', indicator : '&lt;img src="img/indicator.gif"&gt;', tooltip : 'Click to edit...', som...
How to use Jeditable plugin with admin-ajax.php?
wordpress
I'm working on building a custom archives page for my church's website. On my archives page I want to have last week's sermon shown at the top in a special box, followed by the future sermons and then finally the Sermon Archives. I'd like the future sermons and Sermon archives to be separated by a title... i.e. Future ...
You want <code> is_paged() </code> ( see Codex ). This returns true if you are on page 2,3, etc and false if you are on the first page. So... <code> if(!is_paged()){ //Display current / future sermons } //Display archived sermons. </code>
Custom archives function
wordpress
What is the best place to store temporary files for WP plugin which are not necessary for the future? And what is the best place to store files which will be downloaded via FTP?
You could create your own file in wp-content and reference it like so: <code> $cache = content_url(); $cache .= "/cache/" </code> That should echo <code> http://mydomain.com/wp-content/cache/ </code> so you can run all your operations off of that, like systematically clear it. Do the same for downloads if you want them...
Plugin temporary files and files to download via FTP
wordpress
I am trying to customise a plugin to add some functionality that is not part of the original. To do this I have copied all the files into a new folder, and renamed all the function prefixes, changed the header of the main php file. I have tried uploading the files straight to the server for activation but it was not pi...
Unsure of what I did but it seems to be working now. It may have something to do with the fact that I renamed the main php file to try and avoid a conflict. If I keep it the same file name it "registers".
Customised plugin failed to install and activate
wordpress
I have a Development, Staging and Production workflow for my WordPress site. I am fairly strict about any structural work to be done on the site being done in Staging first, then migrated to Production. I feel some changes may be better done on Production through the admin interface, such as a simple logo change, and s...
I make sure the structure (page-title, categories, custom-post types) have the optimal headings and correct structure before migrating. Small changes such as a logo or minor graphics shouldn't effect the quality of the website once moved to production.
Graphic design changes on Staging before moving to Production?
wordpress
I'm trying to intercept the install themes routine in order to alert the user from the active theme. I'm cobbling together a crude javascript alert below. What are some other options? <code> if ( is_admin() &amp;&amp; $pagenow == 'theme-install.php' &amp;&amp; $_GET['tab']=="upload"){ ?&gt; &lt;script type="text/javasc...
I'm usually a fan of doing this kind of work on the server-side since it's far too easy to circumvent JavaScript on the client-side with modern debugging tools, but this is a unique problem and this may fit your use case (depending on who your audience is). Using pure JavaScript, you can do this: Create a JavaScript fi...
Active theme responds to theme change request to alert user
wordpress
On stackexchange-url ("this answer"), there was this final comment For future readers, Roland's issue was a hook priority issue. Changing priority from 10 to 11 fixed it in his case The answer seems already closed, so I couldn't comment, but why/how would a hook priority make an admin menu work or produce a permission ...
Priority All hooks &amp; filters have a priority. Those are used to order the functions that are attached to hooks. By default the priority is <code> 10 </code> . As the default is 10, there's a big chance that your filter/action gets hooked too early and therefore can't affect the actual output. Edit: Imagine that the...
Why does hook priority affects admin menu permission error?
wordpress
I'm having a a pain in the head using the <code> ABSPATH </code> constant in Windows. Addressing files and folders in Windows is usually done using the <code> \ </code> (forward-slash) character while for Linux the character would be <code> / </code> (backslash). Unfortunately the <code> ABSPATH </code> in Wordpress is...
Windows does support both styles of slashes in path. I am not sure if <code> ABSPATH </code> definition is safe to edit: pro it's in <code> wp-config.php </code> con it's says to not edit following above it Myself I just use it as is, or replace slashes to make them uniform when putting path together. If that doesn't w...
ABSPATH in Windows
wordpress
I recently found out that I could use the <code> with-front=&gt;false </code> argument in <code> register_post_type() </code> . So I went and changed my custom post type slugs and did a <code> flush_rewrite_rules() </code> . Now 2 of my custom post types are using the desired URLs and 2 are not. The only difference bet...
The problem is in the register functions, in <code> rewrite </code> , you have to change <code> with-front </code> to <code> with_front </code> .
custom post archive URL is wrong
wordpress
WordPress automatically adds the width and height attributes to [gallery] shortcode images. How to delete these attributes? Something stackexchange-url ("like this") but for [gallery] output.
I can think of a couple of options: Create a new shortcode, e.g. my_gallery. You can copy the code in <code> wp-includes/media.php </code> . Look for the code staring with <code> add_shortcode('gallery', 'gallery_shortcode'); </code> and then the actual function. Rename / modify as needed. The actual img link is within...
Remove width and height attributes from [gallery] output
wordpress
Can someone please help me alter my coding to eliminate my problem? I am using this line before the loop: <code> &lt;?php query_posts('cat=3&amp;showposts='.get_option('posts_per_page')); ?&gt; </code> for context: <code> &lt;?php get_header(); ?&gt; &lt;div id="page-wrap"&gt; &lt;div id="content"&gt; &lt;div class="po...
Try replacing your code with the following: <code> $wp_query = new WP_Query(); $wp_query-&gt;query( array( 'cat' =&gt; '9', 'posts_per_page' =&gt; get_option( 'posts_per_page' ))); </code>
latest post showing up twice on posts page
wordpress
I am using WP-ecommerce to build a shop, and have a random product generator on the left and right sidebar. So the same product doesnt appear twice on the page, I have got the post id's from each product in the left sidebar, and excluded them from the product query in the right sidebar. I am doing this using an array w...
not sure where the code snippet is placed, and where you are trying to access it from. A simple (but ugly) solution might simply be to set this array to be global. Something like <code> $GLOBALS['leftids'] = $leftids; </code> and then from the other code use <code> global $leftids; echo $leftids[0]; </code>
Arrays not working on a WP-Ecommerce product page
wordpress
<code> function t_shortcode($atts, $content = null){ $lang = strtolower($atts['lang']); $content = "&lt;div id='translator' class='translate_".$lang."'&gt;".$content."&lt;/div&gt;"; if($lang == $_SESSION['language']): return $content; endif; } </code> I'm trying to get the content between the shortcodes, apply a functi...
The following adds the shortcode <code> [my_t_shortcode] </code> , which accepts an attribute 'lang', and applys the above mentioned function to the content. <code> //Add shortcodes add_shortcode( 'my_t_shortcode', 'wpse41477_shortcode_handler' ); //It's good practise to make sure your functions are prefixed by somethi...
Get the content inside shortcode and apply external function to it?
wordpress
Is there a plugin which would allow visitors to load comments when they want to, rather than always showing them by default? Preferably through an AJAX call or something to prevent page reload. I'm thinking a nice and visible link or button with <code> View n comments </code> or something along those lines. Hope I'm ma...
A solution oriented around users without javascript: Apply a wrapper <code> div </code> to your comments, leave everything else (including CSS as is) On page load, use javascript to hide the wrapper and display a link or button or something for 'view comments' onclick 'view comments', fade/slide the comments in. The ad...
Plugin for loading comments on-demand
wordpress
In my IDE (Flash Builder for PHP), I can't find a way to create sub project inside Wordpress project as I did with NetBeans. Seems I need to make entire WordPress as a github local repo in order to add version control for my small plugin. Is there other ways I can import git repo as a project inside main project?
There are two ways to make this easier: Set WordPress as a separate project and associate it with your current sub project as shown in stackexchange-url ("this answer"). If 1. isn’t possible manage the Git repository from a terminal and don’t use the limited build-in Git manager in Flash Builder.
Create entire wordpress as a github repositery?
wordpress
I have been entrusted with this site http://equanimityconcepts.com.au and it's running wordpress 2.7. It's theme is a custom designed theme and hasn't had any plugin updates since about 2010. I am hesitant to update anything until I know if and/or how it can be done. Will I need to source every version from 2.7 and upd...
Copy the entire site – including the complete <code> wp-content </code> and the data base – to a local server and run a test. There is no other way to know if it works. Usually you can run the automatic upgrade from any version of WordPress. Outdated themes and plugins are not safe.
Wordpress 2.7 upgrade protocol
wordpress
This is my sidebar code <code> register_sidebar(array( 'name' =&gt; 'Post Sidebar', 'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;', 'after_widget' =&gt; '&lt;/div&gt;&lt;/div&gt;', 'before_title' =&gt; '&lt;div class="titlediv"&gt;', 'after_title' =&gt; '&lt;/div&gt;&lt;div class="widgetdiv"&gt;', ))...
No offense, but your code is a COMPLETE mess, so I'm just going to give you clean code and then tell you how to target it. <code> register_sidebar( array( 'name' =&gt; 'Post Sidebar', 'before_widget' =&gt; '&lt;div id="%1$s" class="widget widget-%2$s"&gt;', 'after_widget' =&gt; '&lt;/div&gt;', 'before_title' =&gt; '&lt...
Unique widget id in sidebar
wordpress
My WordPress website is now redirected to latest post by adding below function to <code> function.php </code> <code> add_action( 'template_redirect', 'redirect' ); function redirect() { $args = array( 'numberposts' =&gt; 1, 'post_type' =&gt; 'seller', 'post_status' =&gt; 'publish'); $last = wp_get_recent_posts($args); ...
Custom query loops and custom page templates are your friends. Ditch the redirect function and on your home page template do something like this: <code> &lt;?php $args = array( 'post_status' =&gt; 'publish', 'post_type' =&gt; 'seller', 'posts_per_page' =&gt; 1 ); query_posts( $args ); // the Loop while (have_posts()) :...
Showing latest post without 301 redirect
wordpress
Is there a way to change the Template of a page from Default Template to another programatically?
Looking at the wp_postmeta table, you can see the page template is stored there. Therefore, a simple call to <code> update_post_meta </code> ( codex ) should do the trick : <code> update_post_meta( $post_id, '_wp_page_template', 'my_template.php' ); </code> The filename and extension is necessary, as per my example.
Programatically changing template of a page
wordpress
I'm currently developing a plugin that uses ajax functionality. Problem: The callback isn't fired = no data gets processed. <code> if ( ! is_admin() ) add_action( 'after_setup_theme', array( 'wpseAjaxClass', 'init' ), 10 ); </code>
The answer was as stupid as simple : I wrapped the <code> init </code> for the class in a <code> ! is_admin() </code> call. This successfully prevented the callback from beeing fired. Rule for AJAX loading Load it in public Don't hide it behind a <code> ! is_admin() </code> call. The 2nd line from admin-ajax.php <code>...
How-to debug wp_ajax_* hook callback?
wordpress
EDIT -- Hopefully my question is more clear What is the best practice for wordpress dropdown menus: Custom CSS (editing styles.css) Using a WP Plugin I'm leaning toward coding it myself from scratch, but I don't want to reinvent the wheel if there's a plugin that is standard.
I personally would do the code from scratch method, rather than get a plugin and have to reverse engineer it to do it exactly the way you want it to work anyway. CSS is defiantly the way to go and the web standard as opposed to jQuery/java, by my understanding at least.
Should I custom code drop down menus or use a wordpress plugin?
wordpress
I want to translate the generic phrase "x hours and y mintues". Of course, if it's only one hour, it should say "1 hour and y mintutes". The same goes for minutes, "x hours and 1 minute." I know <code> _n() </code> handles the single/plural issue, but what is the best practice on handling two numbers in a phrase? Metho...
I would opt for readability and use a rather verbose solution: <code> if ( 1 == $hours and 1 == $mins ) { _e( 'One hour and one minute', 'your_text_domain' ); } elseif ( 1 == $hours ) { printf( __( 'One hour and %d minutes', 'your_text_domain' ), $mins ); } elseif ( 1 == $mins ) { printf( __( '%d hours and one minute',...
How do I translate: "2 hours and 15 minutes"?
wordpress
I have an issue I'm trying to better understand in order to force mce to true in the script check below. Background: I'm applying a rich text editor to the category description textarea to allow users to apply rich text formatting to the category descriptions. The problem I'm having is when the user happens to leave th...
That 'global flag' is called a cookie :) I struggled with the same issue a couple of weeks back, looking for AJAX calls, site options and user preferences until I figured it out. If you check WP's source code for generating the first line of the JS function you're having trouble with, you'll see that 'true' or 'false' ...
Rich text editor settings persist throughout all rich text editors
wordpress
I had a working (test) blog, and during an update from 3.2.1 to 3.3.1 - something went wrong , I think the update did not finished.. Just before the Update, I have enabled a new theme (all functions and files made by me ) Since the update went wrong - I can not access my admin area (500 error) but the front end works j...
In phpmyadmin search : <code> SELECT * FROM wp_options WHERE option_name = 'template' OR option_name = 'stylesheet' OR option_name = 'current_theme'; </code> then : <code> UPDATE wp_options SET option_value = 'yourthemename' WHERE option_name = 'template'; UPDATE wp_options SET option_value = 'yourthemename' WHERE opti...
500 error after update
wordpress
This question I'm asking has been asked a thousand different ways, and I refuse to believe I'm the only one with a basic need here so here goes: I'm taking a simple local install and putting it live. I've exported before, but it didn't seem to carry over any categories/settings/authors/etc. HOWEVER, that was almost a y...
Your easiest option is to just take a copy of your local database and import it to the server using phpmyadmin or similar. You can then add these 2 options to your wp-config.php file to update the site URL. <code> define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); </code> That was you wi...
Export local WP install to live - help needed
wordpress
Does anyone know how I can customise wp-activate.php? It wraps the content in <code> &lt;div id="content" class="widecolumn"&gt; </code> , however in my theme the main wrapper is <code> &lt;div id="main"&gt; </code> Presumably, I could just style <code> div#content.widecolumn </code> to be identical to <code> div#main ...
You are right, this is very hacky. What I ending up doing was creating two new page templates Register and Activate and creating two new WordPress pages using those templates and then using a filter in my <code> functions.php </code> file to modify the behaviour one wpmu_signup_user_notification . Users will register o...
Customizing wp-activate.php
wordpress
I am planning to start work on an urdu (language in pakistan) website theme. basically, it will be a newspaper themed website. Can anyone tell me how can i add urdu support in my theme. I dont want to change Admin UI language. Just whatever posts/pages I will insert should be in my native language. Any positive ideas w...
Take a look at the files for the default Urdu theme to see what is necessary. WP Polyglots has some information too, the most important changes for 3.4 are listed on a dedicated page . I think the main point are the fonts: Don’t rely on the browsers capability to find the best font file, embed a Urdu font per <code> @f...
language support in a custom urdu theme
wordpress
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 <code> functions.php </code> that does a check and removes the custom field if there is no value?
Demilio, unfortunately the WordPress API seems to assume that custom fields do not have an 'empty' value, in the sense that <code> update_post_meta </code> and <code> delete_post_meta </code> , if given <code> '' </code> as the (previous) meta value perform the update/delete operation for all values for that key. This ...
Auto-remove custom field with no value on publish
wordpress
I have a domain-based network. Blogs are like: <code> blog1.domain.com blog2.domain.com </code> One of these blogs needs to be migrated to a domain blog1.com , but without leave the network. I know I have to poing blog1.com DNS to blog1.domain.com with a CNAME register (do it), but I don't know what to do now (in other...
You'll want to use the Domain Mapping Plugin to accomplish this. See the installation tab on that page, it has excellent instructions! Cheers~
Domain name in a WordPress Network
wordpress
I need to generate a simple error message on a page by passing a variable through the URL. The URL is structured as follows: http://site.com/parent-category/category/?error=pause I'm sure it's the permalinks rewrite interfering, but I'm not sure how to resolve it.
Try adding the variable to the WordPress' array of 'recognised query variables'... <code> add_filter('query_vars', 'my_register_query_vars' ); function my_register_query_vars( $qvars ){ //Add query variable to $qvars array $qvars[] = 'my_error'; return $qvars; } </code> Then the value of 'my_error' can be found via <co...
Using $_GET variables in the URL?
wordpress
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 should show all posts and goes to 404 in my archives. I'm using a custom link structure of <code> /%category%/%postname%/ <...
The <code> posts_per_page </code> refers to how many posts per page, and not what page you are viewing. For that, you want to set the <code> paged </code> argument. See the Codex on <code> WP_Query </code> and this article by Scribu. With the <code> paged </code> argument set, it'll return the appropriate posts dependi...
Post Pagination Showing Same Posts Every Page
wordpress
I have created a simple frontend form to allow users to submit posts - similar to the tutorial here - http://voodoopress.com/ . I also have a couple of custom taxonomies which i have as text input boxes on my form. This is all working but i was wondering if there is anyway i can have all the fields including Post Title...
Ok not sure if this is the best method to use but it worked for me. I used a combition of jquery-ui-autocomplete - and the JSON API plugin First download the required js files from the link above. I used jqueri-ui from the Google library Install and activate JSON API plugin I then used the following javascript to auto ...
Autocomplete for taxonomy input boxes on a front end form
wordpress
I am playing with custom meta boxes within WordPress and when trying to modify a drop down menu and saving the option it doesn't save. If I use the default template it saves the option fine. <code> case 'select': echo '&lt;select name="', $field['id'], '" id="', $field['id'], '"&gt;'; foreach ($field['options'] as $opt...
Dan, the problem is that when you save the post meta, it's using a name that doesn't exist as you've added <code> '_team1ban_1 </code> etc, but the code you've linked to looks for inputs named <code> $fields['id'] </code> . If you want to use the linked framework, I suggest you add them as separate fields. (i.e. three ...
Drop down menu's not saving using Custom Meta Boxs in WordPress
wordpress
I have a theme installed but my problem is that the theme doesn't provide a next page function. So if I have 20 posts, and I put 10 in the Blog pages show at most in Reading Setting of Wordpress Setting, it only shows the 10 posts and then I can't anymore see the remaining posts on my home because it doesn't have any n...
You can use the functions <code> next_posts_link() </code> and <code> previous_posts_link() </code> for that. You have to place these functions in your theme where you want the links to be seen. Possible templates for that are your archive.php, category.php depending on your needs. <code> &lt;div class="navigation"&gt;...
How to have a next page for post?
wordpress
I have stackexchange-url ("a function") that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP_Query loop. The custom function: <code> $array = user_albums(); foreach( $array as $post ) { if( !in_array( $post-&gt;ID, $array ) ) $ids[] = $post-&gt;ID; } $access...
<code> $access_ids </code> is a string. <code> post__in </code> accepts an array. So instead of $access_ids you could use <code> 'post__in'=&gt; $ids </code> skipping the <code> $access_ids = implode( ', ', $ids ); </code> all together.
How to make WP_Query 'post__in' accept an array?
wordpress
I'm use the code below to get the number of posts by a user and it works fine but it only includes published posts. How can I modify this code or use different code to have it include "future" post_status's or "drafts", for example. <code> &lt;?php $post_count = count_user_posts($curauth-&gt;ID); echo '&lt;p&gt;User po...
This will do what you want: <code> $args = array( 'author' =&gt; $curauth-&gt;ID, 'post_status' =&gt; array( 'publish', 'pending', 'draft', 'future' ) ); $posts = new WP_Query(); $post_count = $posts-&gt;found_posts; </code> It will include drafts, pending posts, published posts, and future posts. There are more you ca...
Include Drafts or Future posts with count_user_posts?
wordpress
i am having a slight problem with passing php-variables to a stroed procedure call from a php-script. Here comes the details: This is how it works very perfect - passing the params as <code> string </code> : <code> $myHTML = $wpdb-&gt;query( 'CALL show_average_time_spent(2, "2011-10-24", "2011-10-24", @myHTML)' ); </co...
Please take a look at the Codex to see how to <code> prepare </code> your statement: <code> // Example straight copy-paste from Codex $metakey = "Harriet's Adages"; $metavalue = "WordPress' database interface is like Sunday Morning: Easy."; $wpdb-&gt;query( $wpdb-&gt;prepare( " INSERT INTO $wpdb-&gt;postmeta ( post_id,...
passing variables as parameters to stored procedures via wpdb from php-script
wordpress
I have a basic Admin panel allowing Admin to save options using Checkbox. Checkboxes are used as multiple selection is necessary for the option So, Admin Option - Checkbox 1 - Checkbox 2 - Checkbox 3 etc My Checkboxes are generated on the fly, successfully with <code> &lt;input type="checkbox" name="firm" id="firm-&lt;...
Change the name of the checkboxes from <code> firm </code> to <code> firm[] </code> . Then, when you go to save the checkboxes <code> $terms = $_POST['firm']; </code> will give you an array of term slugs that can be checked/sanitized prior to using <code> wp_set_object_terms </code> to add the terms... <code> wp_set_ob...
Taxonomy Checkbox Admin Panel
wordpress
I have a theme, lets call it Master. I manually created a child theme, lets call in Master-Child and added some files into it. All worked well until a notification came that I should update the Master because of a new version. The child theme has failed to work since. I get an error message "Master theme does not exist...
The only string to use the master is <code> Template: twentyten </code> in the style.css if child theme. Check, if this string correct or has the master change this. If you activate the master as Theme in your install, you find the string also in the database of the WP install, in table options, entry <code> template <...
Child theme breaks after update of master theme
wordpress
I'm trying to implement a very simple vertical slide down panel in Wordpress , I've tried jbar (http://tympanus.net/codrops/2009/10/29/jbar-a-jquery-notification-plugin/) and an easy JS method I found in http://jsfiddle.net/ahr3U/ But I still cannot get this implemented, I've tried inserting the below code in the foote...
In order to be compatible with other libraries, jQuery loads in "no conflict" mode by default . Try rewriting your code to use the jQuery keyword instead of $. <code> jQuery(function ($) { $("#notification").addClass("visible"); }); </code>
Getting a 'slide down' js panel implemented within WP
wordpress
Just looking for some history on the output of category_description() I have categories whose "description" fields are formatted with rich text and I'm trying to understand the differences in WP version with respect to the output of this method so that I can do a version check if necessary to implement desired output. ...
Actually HTML is stripped on input, using <code> wp_filter_kses </code> function hooked into <code> pre_term_description </code> filter. So if this hook isn't removed HTML would be stripped.
category_description() shows raw html after version 3.x?
wordpress
Using Get Terms with the argument of 'name__like', how do i return all results that start with any number? I've tried: <code> $feats = get_terms( 'movies', array('name__like' =&gt; '1', 'name__like' =&gt; '2', 'name__like' =&gt; '3' ) ); </code> and <code> $feats = get_terms( 'movies', array('name__like' =&gt; '1,2,3,4...
Looking at the <code> get_terms </code> function definition, the value for <code> name__like </code> will be passed to the SQL query like: <code> " AND t.name LIKE '{$name__like}%'" </code> As such, I believe that you can only search for one of the numbers. As an alternative strategy, you could iterate over the numbers...
get_terms - name__like a number
wordpress
In my gallery site i want to show other pictures under the current picture (in single post). I seen more codes but it i asks to specify the category, but i dont want want specify the category manually in the code I want the code itself to get the category ID or name.It would be much easier for me if i get full posts in...
The question has already been asked and the answer has been posted too, stackexchange-url ("How to display related posts from same category?") Add this code inside your single.php after a loop wherever you want to show related post, <code> &lt;?php $related = get_posts( array( 'category__in' =&gt; wp_get_post_categorie...
How to show related posts by category
wordpress
I'd like to change the title field of a post in admin panel. I'd like this field was "textarea" instead of being "input type='text'". Would it be possible through any hook in functions.php? Thanks in advance!
as this is a default field, i don't think it is possible to achieve what you want with the help function hooks, however you can do this by editing edit-form-advanced.php file inside wp-admin folder, the code you may want to edit is located in line # 291, this is the input type for title field <code> &lt;input type="tex...
Change Title Type
wordpress
I have a multisite network on WP 3.3.1. I now need to get all popular posts from across this network (preferably based on the amount of views). Is this possible, and how do I do that?
simple list all last post about the network, not the popular posts; for popular posts you must use an plugin or track via Google Analytics etc. <code> &lt;ul class='postlist no-mp'&gt; &lt;?php $blogs = $wpdb-&gt;get_results( "SELECT blog_id,path FROM {$wpdb-&gt;blogs} WHERE blog_id != {$wpdb-&gt;blogid} AND site_id = ...
How to get popular post from across a network?
wordpress
I was wondering if anyone could tell me the max length of the meta_value field for posts and user meta. Thanks!
Both <code> usermeta.meta_value </code> and <code> postmeta.meta_value </code> are stored as LONGTEXT. Here's how the MySQL docs describe the size of a LONGTEXT data type: "A TEXT column with a maximum length of 4,294,967,295 or 4GB (2 32 – 1) characters. The effective maximum length is less if the value contains multi...
Max length of meta_value
wordpress
Is it possible to redirect the user to the taxonomy page IF the search input matches the taxonomy name exactly? For instance i have a taxonomy called "Actors". If someone put into the search field "Tom Hanks" instead of going to the regular search page, it would redirect them to the taxonomy page for Tom hanks.
I only wanted to match tags in a single taxonomy, so I was able to simplify the code as follows. My taxonomy is 'post_tag' -- just swap yours out as needed. <code> $i = 0; $search_query = get_search_query(); $term = get_term_by( 'name', $search_query, 'post_tag' ); if( $term !== false ) { $i++; $single_result = $term; ...
If search matches taxonomy
wordpress
I am using contact form 7 with Contact Form to DB Extension. I have this following code for my form. However when I to a test submit only the name and the address populate the database, there isn't even a column for the 4 drop down menus. Not sure why they don't populate the database? <code> &lt;p&gt;Select a day&lt;br...
I think the problem is most likely that you have given all 3 of your select fields the same identifying name "date". Give them each a unique name and that will solve your problem.
contact form-7 drop downs not populating database
wordpress
I'm upgrading a plugin and having issues with dbdelta. Here's the original db creation function: <code> global $jal_db_version; $jal_db_version = "0.1"; function jal_install() { global $jal_db_version; global $wpdb; $table_name = $wpdb-&gt;prefix . "jalPlugin"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9)...
I've never had any luck with dbdelta, it has worked spottily at best, and when I code, that's just not good enough. My method for handling DB changes is to use database versions. So when I create a plugin, I also set the database version, then if I want to update the database, I do a check against the current dbversion...
dbdelta failing with error: "WordPress database error Table 'wp_2_myPlugin' already exists
wordpress
I have been busting my head trying to get the user ID with every piece of code possible but it always comes back "0". Not sure what I'm doing wrong. I started out using this: <code> &lt;?php $user_info = get_userdata(1); echo 'Username: ' . $user_info-&gt;user_login . "\n"; echo 'User level: ' . $user_info-&gt;user_lev...
To use wordpress functions outside the context of the wordpress environment, you can include wp-blog-header.php, so in the context of test.php: <code> require('./wp-blog-header.php'); </code>
wp_get_current_user always returns 0 continued
wordpress
I'm using a customized version of the Twenty Eleven theme. I want to set a class on the <code> body </code> based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based o...
For the TwentyEleven theme, you can place this above your BODY tag in header.php. The theme will recognize that $header_image is already set, so no other mods would be necessary. <code> $header_image = get_header_image(); $image = basename($header_image); $image = explode('.',$image); $class = 'header-image-'.$image[0]...
How to determine which custom header image is being shown
wordpress
I'm setting up a custom page template and I'm building a widget on it that lists albums with track lists. I use a plugin that allows me to expand text which is what I use to show tracks of the albums on click. My problem is adding the information for different artists each time. The idea is to set up the widget on the ...
While I'm not completely sure what you're trying to accomplish, you can use the following to programatically use a shortcode: <code> echo do_shortcode('[DDET]Content goes here[/DDET]'); </code>
Insert shortcode before and after a list automatically
wordpress
I have two simple functions that load stuff using <code> wp_enqueue_style() </code> and <code> wp_enqueue_script() </code> , something like these: <code> function admin_custom_css() { wp_enqueue_style( 'stylesheet_name', 'stylesheet.css') }; function admin_custom_js { wp_enqueue_script( 'javascript_file', 'script.js') ...
<code> add_menu_page </code> and <code> add_submenu_page </code> both return the page's "hook suffix", which can be used to identify the page with certain hooks. As such, you can use that suffix in combination with the variable hooks <code> admin_print_styles-{$hook_suffix} </code> and <code> admin_print_scripts-{$hook...
How do I enqueue styles/scripts on certain /wp-admin pages?
wordpress
i have a file i am including across site to index.php, single.php etc. This file behaves really strage and acts like it not part of wordpress Enviroment meaning: i get errors on get_bloginfo('template_url') and it won't get the values from my options page. Any idea what this might happen? Here is the include code i hav...
The error indicates that your file "floater.php" is being called outside of a WordPress generated page. Add this to the top of the file to be able to use WordPress functions. EDIT: See Brian Fegter response on using the server path for your include. <code> if ( !function_exists( 'get_bloginfo' ) ) require( '../../../wp...
Wp Enviroment problem with included file
wordpress
How do I get the URL of only the first picture in a Wordpress post? I don't want the URL of the thumbnail, but the first picture in the post loop. I only need the URL for linking purposes. Thanks for your help everyone!
The answer is in Codex . Note that wp_get_attachment_image_src returns the URL of an image's full version if you want.
How do I get the URL of only the first picture in a Wordpress post?
wordpress
I have a script which must run in my footer, after some variables are declared. It works if I just put the code directly in my footer file, but I think best practices dictate I should do this via functions.php and wp_localize_script. Unfortunately that doesn't work; the script is always output in the header. Any ideas ...
You should be setting it to show in the footer with the register, so your code should look like this: <code> wp_register_script( 'flowplayer_object', get_bloginfo( 'stylesheet_directory' ) . '/_/js/flowplayer/flowplayer-object-creator.js', array(), // these are your dependencies, if you need jQuery or something, it nee...
enqueue and localize script in footer
wordpress
I am working on a three-column layout where all three columns will have differing content depending on the post/page in the main column. How would I go about giving the ability to change and update the sidebar content and display it in templates using something like <code> &lt;?php the_content() ?&gt; </code> ? Since t...
Add a meta box to the post editor, similar to the excerpt meta box, and get the content of the meta box in your sidebar. If you want to reuse the same text on different pages create a custom post type <code> sidenotes </code> and add a meta box with a select field to let the author choose the text.
Adding content to sidebars
wordpress
I'm just about to start work on a Glossary plugin for my fishkeeping website. My fish guru has suggested that he would like to be able to include images and easily link to other glossary entries. To begin with I was intending just to write a taxonomy : title, slug, description, parent. with parent being the initial of ...
Since, presumably, there would be no more than one image per glossary entry, I would use a custom post type. The CPT should support a featured image, title, description, and excerpt, parents are not necessary, but might make it easier, depending on how your design plays out. To allow categorization of these, I would in...
Writing a custom Glossary plugin
wordpress
sometimes i have Post Titles that contains 2 minus signs side by side (--) but wordpress is always removing one of the minus sign. Looks like: <code> My--Text </code> into <code> My-Text </code> any idea how to disable it? Best regards, Chris
yes I believe you can stop that by disabling the wptexturize function: <code> &lt;?php remove_filter('the_content', 'wptexturize'); remove_filter('the_title', 'wptexturize'); ?&gt; </code> ... for example. You can add that to you themes functions.php file. http://codex.wordpress.org/Function_Reference/wptexturize
WordPress is replacing double minus signs in Post Title, how to disable it?
wordpress
I want my users to first to activate their accounts so they can use all the features in the site. There is a field in <code> wp_users </code> table named <code> user_status </code> which its default value is <code> 0 </code> . I wonder what's that field for? Should I use a <code> user_meta </code> to indicate the activ...
I would use my own usermeta to handle it to avoid having any sort of crossover issues with plugins/future updates. It should also allow you greater flexibility in what you store in the usermeta.
User activation in wordpress
wordpress