question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Just looking for some advice on something that is bugging me. Please bear in mind I am a PHP noob :-) I am passing a variable in the url to my WP index page like so: <code> &lt;a href="&lt;?php bloginfo('url');?&gt;/?do=thing"&gt;Thing&lt;/a&gt; </code> I am the catching that variable, and using it to show content like...
The error is occurring as the $_GET array doesn't have the item $_GET['do'] in it. Therefore it throws this notice. To check if something exisits in the array try: <code> if( isset( $_GET['do'] ) ) $do_that = $_GET['do']; else $do_that = ''; </code> or a cleaner method would be to use short hand notation <code> $do_tha...
Using a _GET gives me a debug error (over my head)
wordpress
In my theme, i want to create a generic way of inserting a meta box to a post, page, portfolio or other custom item. For now, this action is like : <code> add_action('admin_init', 'add_portfolio_settings'); </code> Which works fine, but has a problem. It currently works only for creating an add_meta_box for a portfolio...
What you want is quite possible, but not exactly mainstream technique. Take a look at my stackexchange-url ("Implementing advanced add_* function wrappers") question. However your real issue here is not being unable to pass arguments. It is lack of context. The simplest way to track context is inside your hooked functi...
add_action for admin_init hook with a parameter
wordpress
Right now by blog has the 'home' section where all my new posts go, and 'pages' sections which are static pages that i can edit. my question is, can i have another section that will behave like the 'home' link? for example, can i have a page called 'cars' and a section called 'cats', where i can add new posts to either...
You can also create a custom feed and this to WP; use the function add_feed() for add a feed to wordpress and define the content inside the feed. A example for feed with the draftsa of WP you can see on this post http://wpengineer.com/424/feed-for-drafts-plugin/
can i create 2 blog 'feeds' within one blog
wordpress
Short Version I need to give in the absolute path of a Javascript file that is to be hooked into something. It works if I hardcode it into 'http://mywebsite.com/folder/script.js' However I prefer not to hardcode it in. I can do <code> dirname(___FILE___) </code> , which gives me this: '/home/public_html/folder/script.j...
Assuming your resource is included in your Plugin: <code> plugins_url() </code> is the URL to <code> \wp-content\plugins\ </code> ( Codex ref ) So if you have a .js file in <code> \wp-content\plugins\plugin-slug\file.js </code> : <code> &lt;?php echo plugins_url() . '\plugin-slug\file.js'; ?&gt; </code> BUT WAIT!! If y...
How can I find the 'public absolute' path of a file?
wordpress
I am on a (non-hosted) server...what level of permissions should my plugins folder (and everything inside of it) be set to? I seem to be having issues deleting or moving files inside of this folder...
Typically, the plugin folder only needs to be writable by your user account, but this could potentially vary depending on what user your web server is running as. For example, most of my installs have the plugins folder set to 755, but this is because Apache is running as the same user as the owner of the folder. Check...
What level of permissions should the plugins folder be set to?
wordpress
I am displaying the wordpress posts on the index page with: <code> &lt;?php the_excerpt(); ?&gt; </code> In my functions.php file I have following code: <code> add_filter('excerpt_length', 'my_excerpt_length'); function my_excerpt_length($length) { return 30; } </code> This works fine but it shows <code> [...] </code> ...
Use the <code> excerpt_more </code> filter hook: <code> function mytheme_excerpt_more( $text ) { $text = '...'; return $text; } add_filter( 'excerpt_more', 'mytheme_excerpt_more' ); </code>
Remove [ and ] from excerpt
wordpress
I am using PowerPress for my podcast support. I am working on some things on the web site and I swear, I set the enclosure, verify via phpMyAdmin that it is there. I don't touch anything on the site and check minutes later and the enclosure is missing. Huh?!? Does anyone have any ideas where to start looking? I am runn...
Okay, looks like this is a "feature" .
Enclosures being deleted "automatically"
wordpress
This is the manual page and this is the code . But I'm still struggling to understand how to use this function. Perhaps I am using it right, but something I can't think of is wrong. But more surely, I need to know what this means: <code> callback </code> - I assumed this was the name of the Widget class. Am I right? <c...
You should make the check inside the widget class, unless you don't have a choice. The example in the codex is pretty much what you're looking for: <code> class cbs_map_widget extends WP_Widget{ function cbs_map_widget(){ $this-&gt;WP_Widget('cbsmaps', __('Widget Name'), array('classname' =&gt; 'cbsmaps', 'description'...
How to use is_active_widget?
wordpress
What i'm trying to do here is to modify the existing wp-postratings plugin. The function to display the ratings is: <code> &lt;?php if(function_exists('the_ratings')) { the_ratings(); } ?&gt; </code> However, the above code displays the ratings on every post. What would be the conditional statement to add such that if ...
<code> &lt;?php // get the value of our custom field $meta_value = get_post_meta($post-&gt;ID, 'ratings', true); // if it's not empty and the_ratings function exists: if( !empty($meta_value) &amp;&amp; function_exists('the_ratings') ){ the_ratings(); } </code>
How to display a feature only if custom field value is set?
wordpress
No matter what I try I can't seem to get the code snippets to work that will display the number of followers of Twitter. I tried various ones as the Plugin I'm using is not showing the Twitter number at all, so I need to look for alternatives. When I tried this snippet , for example, I got the following error message: ...
Ouch, that snippet is ancient (I am kinda its author, more precisely adapted to twitter from other snippet). I would strongly consider using some newer solution. I had later made newer and written from scratch version, try it http://www.rarst.net/script/twitter-counts-wordpress/
Show Twitter followers count snippets don't work
wordpress
I had a site that was hacked (had Arab words on the index.php), and all files deleted, but database still there. I used Fantastico to install a clean release of WP 3.1, and I still some something suspicious. In lower right side of Firefox it says "Read www.clickcoupon.me". With FireBug and PageSpeed, I can see it's ope...
Found it! It was happening in FireFox but not Chrome. I looked at all my FireFox Extensions, and found "Browser Enhancements 1.0" and "Browser Coupons 1.0" http://www.webenhancements.me/ . The other URL was searchdock.me, and was reported as a "threat" here: http://www.threatexpert.com/report.aspx?md5=af6cc99d717c0daef...
Suspicious URLs being loaded after hack and restore
wordpress
I'm trying to use a jquery toggle shortcode in a theme template. The shortcode goes like this: <code> [sws_toggle3 title="Title"]You can now see the displayed text.[/sws_toggle3] </code> I want to pull posts from a specific category and use the toggle to display them in the page. This is what my theme template currentl...
You should be able to use <code> do_shortcode() </code> , with a few modifications: <code> &lt;?php echo do_shortcode( '[sws_toggle3 title="' . get_the_title() . '"]' . get_the_content() . '[/sws_toggle3]' ); ?&gt; </code> EDIT If you need to maintain the formatting of <code> the_content() </code> , simply pass <code> ...
Populating shortcode values dynamically in theme template
wordpress
I have a list of 350 or so terms that I am trying to set to a post. Here's my code: <code> add_action('init', 'add_cities_to_story'); function add_cities_to_story() { $cities_list = get_term_children('115', 'location'); // MA wp_set_object_terms('632', $cities_list, 'location'); } </code> The trouble is that it appears...
Dealing with terms is known to be very heavy operation. The common tweak recommended is to use <code> wp_defer_term_counting() </code> to temporarily disable updating of terms count (which is stored persistently in database and so must be updated when you change terms).
wp_set_object_terms timing out?
wordpress
I have registered custom post type Article in my template using register_post_type function. and i also having taxonomy category for this article posts. Here i want to filter the posts under particular category. using query post How can i do this Thanks in advance !
If you read http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters in detail it outlines everything you need. Take a look at the following code sample taken from the codex. It should help you :) <code> $args = array( 'post_type' =&gt; 'Article', /* This is where you should put your Post Type */ 'tax_qu...
how can i get posts from custom post type particular taxonomy category
wordpress
I have a query like this; <code> &lt;?php $temp_query = $wp_query; ?&gt; &lt;?php foreach(get_the_category() as $category) { $cat = $category-&gt;cat_ID; } query_posts('orderby=date&amp;cat=' . $cat . '&amp;order=desc&amp;posts_per_page=-1'); ?&gt; </code> It grabs all the posts from the current category. What i then d...
save the main current post id into a variable and compare it in the loop with the current post id; example: <code> &lt;?php $this_post = $post-&gt;ID; ?&gt; &lt;?php $temp_query = $wp_query; ?&gt; &lt;?php foreach(get_the_category() as $category) { $cat = $category-&gt;cat_ID; } query_posts('orderby=date&amp;cat=' . $c...
Add class to current post in query_post
wordpress
I would like to show a plugin in a specific page's sidebar only. For Example: I have the pages like .. home about us sub page 1 sub page 2 sub page 3 sub page 4 UPdate: i want to show, plugin 1 in sub page 1 and sub page 4 only and not to all other pages.i tried <code> is_page('sub page 1','sub page 4') </code> but not...
The way to use is_page with multiple pages is as follows: <code> is_page(array(42,'about-me','Contact')); </code> You have to use the <code> array </code> keyword
How to show my sidebar in specific page only?
wordpress
I am looking for a gallery plugin that will allow users to comment on each individual photo as opposed to the entire gallery. I have tried Lazyest Gallery ; however, it doesn't seem to be integrating well with another plugin I have installed called Facebook Comments for WordPress which I'm using to replace the default ...
Usually your Wordpress theme will have an "attachments.php" page that would have a "single view" of the image in question. For an example: http://twentyelevenphoto.wordpress.com/2011/05/25/an-image/mcm_5276/ That gives you a "single" view of your image as well as comments. To test to see if your site has this, create a...
Any gallery plugins that allow commenting on single images?
wordpress
I am trying to delete some plugins via the Wordpress admin panel. Sometimes it deletes the plugin quite quickly, but other times it hangs. I have access to my server, is there anything I can do to speed the performance up?
Is it a shared hosting? Try rising the php memory limit. That will make wordpress admin go faster and your blog!
Wordpress FTP via admin panel slow
wordpress
Here's my setup. I have a Multisite instance running at http://example.com, and I want to do development and staging. Moving an existing Multisite instance of WP onto localhost is a nightmare, so I'm going to do dev on a staging location instead. I set up http://staging.example.com to point to the /public_html/staging/...
One thought - when I go to www.example.com/staging/wp-admin it automatically redirects me to www.example.com/wp-admin Could the redirect from staging.example.com to example.com/staging be conflicting with the existing install? UPDATE: looks like it could be related to .htaccess issues and complicated domain references ...
DB connection error after copying a WordPress Multisite instance to a second location
wordpress
I want to use built-in WP media gallery. I'm trying to simply add images in one - horizontal line. I want images with original size and without any link. I'm trying to add/edit some code into wp-admin/includes/media.php but I can't get it ;/ I know I have to use size="full" and columns="0" but how to add this with shor...
UPDATE I've just submitted a core patch to add <code> link="none" </code> support to the <code> [gallery] </code> shortcode. ORIGINAL ANSWER You don't need to hack core to do what you want to do; just use the appropriate <code> [gallery] </code> shortcode parameters , e.g.: <code> [gallery columns="0" size="full"] </co...
Media gallery - inserting full size images without link
wordpress
I've added a custom post type, on the 'init' action, like so: <code> // Setup the 'Classifieds' Post Type $labels = array( 'name' =&gt; _x('Classifieds', 'post type general name'), 'singular_name' =&gt; _x('Classifieds', 'post type singular name'), 'add_new' =&gt; _x('Add New', 'classifieds'), 'add_new_item' =&gt; __('...
you need to specify the post_type in your <code> $data </code> array : <code> $data = array( 'post_type' =&gt; 'classifieds', 'post_content' =&gt; stripslashes($output), 'post_title' =&gt; stripslashes($title), 'post_date' =&gt; date('Y-m-d H:i:s'), 'post_category' =&gt; array($cat_ID), 'post_status' =&gt; $statusPost,...
Programmmatically adding a Custom Post
wordpress
I have added several new fields to the user profile (areacode, company, affiliate, etc) and I would like to present a way to search on these fields. Please point me in the right direction.
I just had a project where i needed to create a search by user meta form and i ended up creating a shortcode for it, i just altered it a bit to show you how to make it work with your fields, so just paste this code inside your theme's functions.php file or a plugin file: <code> add_shortcode('user_search','My_User_sear...
How to search for users based on added user metadata
wordpress
I've just started developing a WP plugin, and i've been reading some code from other plugins as a way to get started. I've seen a couple of plugins that wrap all or some of their functions in the following code: <code> if(!function_exists('my_function')) { function my_function() { // a cool function } } </code> Is it c...
I would not do this to prevent naming conflicts: if another unrelated plugin uses the same name, it's unlikely that they will provide the same functionality and your plugin can continue as normal. There you want to fail early, not sneaky later on. Or prevent the conflict with a better prefix of course :-) The only reas...
When to check if a function exists
wordpress
I have a custom post with a lot of meta boxes. I recently tried to add some dynamic metaboxes, using this question: stackexchange-url ("Create more Meta Boxes as needed") I managed to get the metaboxes to add nicely, the jquery works, everything works except the save_post action - the "Reviews" save nicely, but the "Sc...
Following are the issues that were preventing from the meta values to be saved in both of your save functions. 1. Incorrect post_type checking. You are checking post type to be of 'page' in your save function where as your meta boxes are being displayed on your custom post type of 'film'. Your code: <code> if ( 'page' ...
Why won't my metabox data save?
wordpress
I am working on a site that has the option of using Event Expresso Event Manager Pro The events part of the site is quite complicated, and needs to have - a calendar - a registration page - 'buy tickets' functionality with both Paypal and http://www.authorize.net/ - email confirmations I haven't worked a lot with event...
I know this does not meet your requirement of supporting Paypal and Authorize.net, but it does support Eventbrite, so it may be worth looking into: The Events Calendar
Event Management plugin
wordpress
So hard to find this info... I'd like to know a way to find out if there are pages. Something like: <code> if (has_pages()) { /* do something */ } </code> I can't find a reference to any similar function... how might one go about finding out if there are pages. In case yr wondering I'd like to only show a pages menu if...
You could also use <code> wp_list_pages() </code> ( Codex ref ): <code> &lt;?php $has_pages = wp_list_pages( array( 'echo' =&gt; false ) ); if ( $has_pages ) { // There are pages; do something } ?&gt; </code>
Check if has pages?
wordpress
I'm building a database of cities as a part of a "location" taxonomy. In order for the terms to render, as far as I've found, they need to have some type of content associated with them. My work-around is to create a "placeholder" post, assign it to the respective terms, then move it to the trash. So, first, if you hav...
With functions like get_terms, there is an argument hide_empty that will allow terms without associated posts to be shown. Set hide_empty to 0 and you will see your terms.
How do I assign a custom post to all terms in a custom taxonomy?
wordpress
I want to add "print" button to print simple reports in a plugin. The basic idea I have is to generate a printer friendly html page and redirect user to that page where he/she can use browser's print functionality. How good is that solution? Is there any other alternative?
check out WP Print Friendly plugin which extends WordPress template system to support printer-friendly templates. Works with permalink structures to support nice URLs.
"Print to printer" functionality in a plugin
wordpress
So I have created a custom post type with custom values and customize my custom post type admin columns. You can see here how my custom post type is looking in admin panel. And as you can see I can order by title all posts and I was wondering if I could do same for all columns, like "info" etc. Is it possible? I am usi...
Scribu as written a great detailed tutorial named " Create your own sortable columns " just what you need.
Custom post type - columns order
wordpress
I rent some webserver space (Linux, MySql, PHP, Apache) and host several Wordpress websites (for different clients, with different needs) What would be the best way to Host multiple wordpress sites on a single machine, what I'm looking for here, is saving on diskspace and number of databases needed as well as simplifyi...
Based on your needs, yes: you should probably be using a Network (WordPress with MultiSite enabled). All network sites run the same version of WordPress Each network site can activate its own Plugins. You can explicitly allow each site to manage its own Plugins. Each network site can have access to different Themes (th...
Hosting multiple Wordpress sites on single server - best practices?
wordpress
I am trying to add the parent category class in post_class() of some posts from one of my subcatgories. I have an advanved theme so I need to style all the posts from the parent cateogry using it's class, not the subcategory class (too much hassle in CSS).
Perhaps something like: <code> function mytheme_get_post_class_parent_cats() { $parent_cat_classes = array(); // Get parent categories $post_cats = wp_get_post_categories(); // Loop through post categories foreach ( $post_cats as $post_cat ) { $cat_parents = get_category_parents( $post_cat , false, ',', true ); // if t...
Get parent category class in post_class()
wordpress
I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as <code> /page/2/ </code> , my query breaks because the url isn't correctly matched. I'm very new to php and in my searching I've come across a few different php functio...
look for the string <code> page/ </code> and capture just the part of the url before it with <code> strpos </code> and <code> substr </code> : <code> $url = '/players/type/pros/page/3/'; $find = 'page/'; $trimmed_url = substr( $url, 0, strpos($url, $find) ); </code> EDIT - so in the context of your question you could u...
Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
wordpress
I use excerpts of posts in my front page. In my excerpt, the summary of the post seems to be clumped together with no spaces that are indicated in the post (e.g., paragraph spaces are automatically removed). I understand this is the default behavior. Question: Is there a way to retain the paragraph in excerpts? To show...
Looks like my other answer wasn't working, so I looked into it and found this: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ That article should give you all you need to keep the <code> &lt;p&gt; </code> tags in there.
Excerpts automatically remove paragraph space
wordpress
Does anyone know where I can get a list of all the body classes generated by <code> body_class() </code> for every sections and every conditions , including custom post-types , etc.? For example, for a search result page with certain conditions (eg. logged-in ), the function produces this: <code> &lt;body class="search...
Several classes have been added since WordPress 2.8 (when the WPEngineer post was written). I would refer directly to the <code> body_class() </code> Codex entry , which currently lists the following: rtl home blog archive date search paged attachment error404 single postid-(id) page-id-(page_id) attachmentid-(id) atta...
List of Body Classes Generated by body_class()
wordpress
I have a custom post type called "stock" and each post is going to have a stock_id, stock_name, stock_description and stock_available fields,...I would like to have defaults for these fields so the user doesn't have to load them on each new item. Is there a way?
A simple way to do that would be to use Verve Meta Boxes plugin which lets you define a metabox with a simple UI ( no code is needed ) and you have an options to set the default value for each field.
preselected custom fields in custom post type
wordpress
Currently my only internet access is via my phone, and I need to add a widget to a Wordpress site. This requires dragging and dropping the widget to the sidebar, which I cannot do via the web browser on the device. Is there some way to get around this?
Yes at the top of the page click on "Screen Options" then click "Enable accessibility mode" ,
How do I add a widget from an Android phone?
wordpress
I just built a theme for a client. I am wondering what is the best way to make footer content editable through Wordpress. The footer info looks like this: Company Name Address Line 1 Address Line 2 Phone and Fax Email (linked with mailto) I have some ideas on how to do this: Make a page called footer and grab the conte...
I would go with a Widgetized footer. If you want to go the extra mile, rather than create Theme Options, simply create a custom Widget, e.g. Footer Contact Details, that has editable text inputs for Company Name, Address Lines 1 and 2, Phone/Fax, and Email.
Editing Footer Information
wordpress
I have the following code that prints a comma separated list which I need in the form of an array, how do I get the list of id's into an array called $excluded_categories with contents as per below? <code> $categories = get_categories(array('taxonomy'=&gt;'projects_category', 'exclude'=&gt;7, 'orderby'=&gt;'id')); if (...
WP has a lot of nifty functions in the corners for such stuff. Try this: <code> if ( !empty( $categories ) ) { $excluded_categories = wp_list_pluck( $categories, 'term_id'); $excluded_categories = implode(',', $excluded_categories); } </code>
Comma seperated list of ID's as an array?
wordpress
I have a custom post type of <code> players </code> , and archive-players.php lists them all at an address such as <code> www.site.com/players </code> . I'm then using a url like <code> www.site.com/players?type=pro </code> to list another page of just the pro players (modified wp_query based on custom user role, hence...
You have to add another rule which maps the /page/# to the &amp;paged=# variable. Really though, you're kinda doing it all backwards here by filtering the rules array. Just calling add_rewrite_rule to add your rules makes a bit more sense. <code> function plugin_name_add_rewrite_rules() { add_rewrite_rule('players/type...
How to fix pagination after rewriting url? ie. www.site.com/players/type/pro/page/3/
wordpress
I was just reading the Codex regarding <code> get_terms(); </code> . What exactly is the parameter <code> 'term_group' </code> ? You can use it in ( example ): <code> 'order_by' </code> for <code> get_terms(); </code> . Hint: I could be all terms that share the same names, but have different slugs.
The idea of term groups was to have a term with multiple aliases. This feature doesn't seem to be fully backed and is therefore practically never used.
What is 'term_group' for 'order_by' in get_terms()?
wordpress
My question resembles one I asked before: stackexchange-url ("[Plugin: Posts 2 Posts] Changing display order of connections") But now I want to display the connection in the SAME order I created them ! That is, if I attache quote#1 THEN quote#2 to an article, I want quote#1 to appear before quote#2 regardless of the cr...
With the development version of the plugin (0.8-alpha), you have a 'p2p_orderby' query var, which you can use with WP_Query, like so: <code> $my_query = new WP_Query( array( 'connected_to' =&gt; get_queried_object_id(), 'p2p_orderby' =&gt; 'my_connection_field' ) ); </code> More info on connection fields: https://githu...
[Plugin: Posts 2 Posts] Controling the display order of connections
wordpress
I've created a custom post type with categories and sub categories, what I need to do is list out the post titles and images for a given sub-category or category in a page template. I've got as far as getting the all the listed items in the custom post type, but I'm unsure how to go further... any help appreciated. <co...
This is a version of a function I'm using in the framework I'm working on, with example html replacing another function that contains something like it. <code> // Custom Loop function arrr_custom_loop( $r_type = 'post', $r_post_num, $r_tax = 'category', $r_terms = 'featured' ) { $args = array( 'showposts' =&gt; $r_post...
Get custom post type by category in a page template
wordpress
I've used the Smart YouTube plugin to embed YouTube videos into my blogs. The way I did it is to replace the <code> http:// </code> of the YouTube url with <code> httpv:// </code> as the plugin describes. But now I noticed that it's much easier to just auto-embed the YouTube videos by posting the normal <code> http:// ...
I like to use the Search Regex plugin for mass post editing. http://wordpress.org/extend/plugins/search-regex/
Rename Smart YouTube's httpv back to http for all posts
wordpress
I'm using the code below from another answer to query posts from 1 custom role, eg "friends". I thought I could just comma separate the roles to list posts from more than one role, but this didn't work. Is there another way I can write it? I've tried <code> 'role' =&gt; 'friends', 'enemies' </code> and <code> 'role' =&...
Just do the get_users() twice and merge the results: <code> &lt;?php $friends = get_users( array( 'role' =&gt; 'friends' ) ); $enemies = get_users( array( 'role' =&gt; 'enemies' ) ); $friends_n_foe = array_merge($friends, $enemies); $IDs = array(); foreach( $friends_n_foe as $person ) { $IDs[] = $person-&gt;ID; } $news...
How can I query posts from multiple roles?
wordpress
I use this code for display custom posts : <code> $args = array( 'category__in' =&gt; $bookcat, 'meta_query' =&gt; array( 'relation' =&gt; 'OR', array('key' =&gt; 'bookname','compare' =&gt; 'LIKE','value' =&gt; $bookname), array('key' =&gt; 'authr','compare' =&gt; 'LIKE','value' =&gt; $authr), array('key' =&gt; 'transl...
Looking at your code it looks perfectly fine. Although the more complex you make your query the more resources it is going to take and the longer it is going to take. You mention that your CPU usage rises to 80% which would be normal but how long is the usage holding at 80%? If its for a very short while then I wouldn'...
WordPress & MySQL , problem with use many array in meta_query
wordpress
Company I work for has purchased an eCommerce solution for WordPress. The solution works as a complete WordPress Theme. My assignment is to split the store view from the original website design. To be more precise, website we are working on has a unique design, but when we install the store theme, the whole website the...
Core site functionality really shouldn't be so tightly coupled to the theme. This is why the plugin system exists. If it's not too late I would recommend exploring alternatives. That said, anything happening on the admin side is in the theme's <code> functions.php </code> file, or is included via that file. As long as ...
Splitting an eCommerce store from the WordPress Theme
wordpress
Hey guys i'm creating a site network using WordPress. Lets say my site name is blahblah.com and lets say i have 10 subdomains like site1.blahblah.com,site2.blahblah.com Now i want something like this. There will be no articles in my main domain. But i want list all subdomain's articles in my main domain. When they clic...
There are two plugins that do exactly what you want, and I have used them both extensively. First, ThreeWP-Broadcast . This plugin lets you "broadcast" posts from your sub blogs to your main blog (or the other way around). It also allows you to link to broadcasted post to the original, as well as auto create tags, cate...
Please suggest me some plugins in WordPress networking
wordpress
My nginx user is www-data. If I do <code> su www-data </code> I can create both file and directory. But when installing plugin I am asked for FTP credentials. I tried to give the public_html directory 777 permissions for a while to test if I can install plugin without providing FTP credentials but it didn't help either...
You can set this in the wp-config.php, check the Editing wp-config.php page in the docs.
What are the correct permissions so WP doesn't ask for FTP credentials if installing plugin?
wordpress
I'm trying to redirect certain users to a part of my site but I cannot seem to make it work... can you take a look at this and tell me what I'm doing wrong? <code> if ( ! function_exists( 'redirect_after_login' ) ) : function redirect_after_login() { global $user_ID; if ( $user_ID === 4 ) { global $redirect_to; if (!is...
Try <code> wp_redirect() </code> . And don't forget to exit.
problem redirecting users to page on login
wordpress
If I upload a large size image inn my wordpress, the image breaks my template width. I have seen some templates which scale the large image's width to the maximum width of the post div. What CSS or code I need to change for that purpose? Thanks.
In your <code> functions.php </code> file, you need to define <code> $content_width </code> , which will cause WordPress to scale large -size images, and also embedded videos, accordingly. e.g. if the width of your content area is 600px: <code> if ( ! isset( $content_width ) ) { $content_width = 600; } </code> You will...
Large size image breaks template layout
wordpress
Here's my custom function to list child categories by the parent slug. <code> function ribbon_list_cats($parent_cat_slug) { $parent_category = get_category_by_slug($parent_cat_slug); if ($parent_category-&gt;count != 0) { echo "&lt;ul&gt;"; echo wp_list_categories('title_li=&amp;child_of='.$parent_category-&gt;term_id....
<code> function ribbon_list_cats( $parent_cat_slug, $echo = true ) { $parent_category = get_category_by_slug( $parent_cat_slug ); if ( $parent_category-&gt;count &gt; 0 ) { $output = '&lt;ul&gt;'; $output .= wp_list_categories('title_li=&amp;child_of='.$parent_category-&gt;term_id.'&amp;hide_empty=0&amp;show_option_non...
Having Trouble With get_category_by_slug In a Custom Function
wordpress
I currently have a site with two levels of navigation. I am styling the wp_list_pages() list to act as my navigation. I would like to disable the link on some pages which have children (not exclude) so that I can hover over them to display the drop down navigation but I can't click on them. Does anyone know of such a m...
You could go to the wordpress menu and make the target of the link a #. If the user clicks on it, they are taken to the top of the page where they probably are anyway since they're using the navigation.
Disable the link on certain pages
wordpress
How can I remove "edit your profile" submenu under "my-account-with-avatar" admin menu bar, while still keeping the avatar and logout?
There is a <code> remove_menu </code> hook for the admin menu bar. The class you want to hook into <code> $wp_admin_bar </code> , you can see the remove function here and test it out since there is no documentation on it ( line 86), it should work with the submenu ID. http://core.trac.wordpress.org/browser/tags/3.2.1/w...
remove "edit your profile" from admin menu bar
wordpress
As I am a novice in web development field, I wanted to clarify some questions running in my head. I want to make a multilingual website with dynamic features. Dynamic features can be like anything under the sun. Is it possible that I can make a website using WordPress (which is mostly considered as blogging platform). ...
1) Yes you can 2) No, but spend a lot of time reading up on wordpress codex (thats more or less your bible) and of course refernce through this site too, full of valuable information. 3) Everything is very easily added to wordpress via plugins, no need to go on steep learning curves 4) Wordpress is probably the most si...
How can I make a website with dynamic features with wordpress?
wordpress
I am following this tutorial to post from front end. I am able to post the title, content, category, tags, I would like to know is it possible to add more fields like in the image below. How to increment field-set? and how to add edit the post from the front end itself? basically this what I want to do.
I believe it is better if you use the ajax method instead of sending the POST to the same page. You can use javascript to increment the form / fieldset. Use an array for the name e.g <code> &lt;input type="text" name="ingredient[]"/&gt; </code> If you want to edit the post, just you us the saved data on the value attri...
Post & edit a post from front end along with upload, dropdown, and other inputs
wordpress
On a freshly built site running version 3.1.3 with the twentyten theme active and no plugins, when I click on "Media" to go the media manager, I'm getting this error: Warning: explode() expects parameter 2 to be string, array given in C:\xampplite\htdocs\testsite\wp-includes\query.php on line 2390 Warning: in_array() e...
Quick look at source for that version shows parsing <code> post_status </code> argument. It's probably this bug that got fixed in 3.2 . Upgrade. :)
Warning: in_array() expects parameter 2 to be array, null given
wordpress
Relevant link: http://themeforward.com/demo2/2011/01/17/testing-comments/ I've been toying with this for about 10 minutes, trying to get the sidebar to align properly and I can't figure it out. I placed my comments in a new DIV to separate them from the posts. Usually I wouldn't do this but I want designers to have ful...
Put content and comments into a container div with float: left; and then add the same to your sidebar.
Unable to align my sidebar to the contents section instead of comments
wordpress
I was trying to clear up some empty tables left behind by other previously used plugins. As such i was trying to delete the GD Star rating plugin and now I cannot access my WP admin. i get the <code> 'You do not have sufficient permissions to access this page' </code> I turned on the debug to true and saw the errors ca...
since i posted as a comment and most people miss the good tips that are in the comments, I'm posting again as an answer The reason is because <code> GD Star rating </code> plugin creates custom capabilities and your query deleted all references of <code> %rating% </code> it deleted the <code> wp_user_roles </code> opti...
Help!! I Screwed up my WP
wordpress
I'm doing a category-based search that looks like this: <code> $feed = WP_Query("category_name=noticias&amp;showposts=3&amp;order=DESC"); </code> The problem is this also brings me posts from the child categories, which I would like to avoid... how do I do this? If I do something like <code> $feed = query_posts(array('...
you can use the <code> 'category__in' </code> in WP_Query; example: <code> $feed = WP_Query(array('category__in' =&gt; array(102), 'posts_per_page' =&gt; 3, 'order' =&gt; 'DESC')); </code>
how do I exclude child categories from a wp_query?
wordpress
I have 500x300 sized images in my all post and want 280x177 sized images to display in index page for all the post. I used regenerate thumbnails and AJAX thumbnail rebuild plugin which builds images using setting in media section but problem is that after building some of the images it stops reacting and just hangs. Wh...
Very likely, your issue is the large number of images, causing the processing to time out. Try increasing your PHP script execution time, and see if either Plugin can complete. Alternatively, I believe that one or both of those Plugins allows for manual thumbnail regeneration, via <code> Dashboard -&gt; Media </code> .
How to regenerate image thumb with size that is specified in media section
wordpress
I have a blog with all the plugins I need committed to an internal svn repository. Wordpress is showing that some plugins need to be updated but when I do, Wordpress will delete the folder for that plugin so the .svn files are deleted as well. This will break the repository for that plugin. Any way around this?
a simple way around this is to update the plugins by SVN from the plugin repository.
Updating a Wordpress plugins breaks SVN
wordpress
I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query <code> while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); </code> style I'm accustomed to and have built a lot of shortcodes and loop styles around. How ca...
In order to be able to use template tags, you have to do two things after getting your custom select query: You have to declare the <code> global $post </code> variable. You have to call the setup_postdata($post) function to populate the variables. So, my code had to be changed like so: <code> $results = $wpdb-&gt;get_...
How to change a custom query into a standard loop?
wordpress
I was just wondering if calling get_bloginfo too many times was going to harm performance in a theme and if the data should just be put into its own var?
<code> get_bloginfo() </code> is not cached and calling it over and over would harm your performance just like creating many calls to the database yourself. a simple solution which doesn't evolve any caching in to minimize the database and function calls by defining a an array with all the info you need and save that a...
Are get_bloginfo queries cached to start, or should they be cached?
wordpress
How can I remove the next and previous links in a custom post type archive page, but only for that post type? I know I could wrap any function in <code> if ( get_post_type($post) == 'myposttype' ) {} </code> but I can't find a solid snippet to remove the pagination. I have tried a few solutions, stackexchange-url ("thi...
Got it figured out... While I did manually remove the next page links, CloudFlare's cache was not playing nice.
How to disable pagination (next/previous links) on post type archive?
wordpress
I have a short code that is adding a form to a page. How do I ensure that the CSS for the form is loaded in time with the shortcode?
you can check with <code> the_posts </code> hook if your shortcode exists and only enqueue the style if so : <code> function check_for_shortcode($posts) { if ( empty($posts) ) return $posts; $found = false; foreach ($posts as $post) { if ( stripos($post-&gt;post_content, '[CHANGE_TO_YOUR_SHORT_CODE') ) $found = true; b...
Custom CSS for plugin form
wordpress
I am using 2011 theme, any how I managed to get sidebar on single.php pages by installing child theme, But now I want sidebar on pages, How do I get it?
Funny you should ask, I've just posted an How to tutorial on how to add a sidebar on posts and pages in Twenty Eleven
Worpress twenty eleven sidebar on Pages
wordpress
Is there anyway to rename a user role name via hook, instead of using plugin?
<code> function change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //You can list all currently available roles like this... //$roles = $wp_roles-&gt;get_names(); //print_r($roles); //You can replace "administrator" with any other role "editor", "author", "contributor" or "su...
Is there way to rename user role name without plugin?
wordpress
I have a custom post type with its own date field. the date is setup for unix YYYY/mm/dd I need to create a simple month calendar that shows days that have a cpt on them. get_calendar works for posts but not a CPT.
You can put a custom function into your functions.php to show a calendar with CPTs. Details here .
how can I create a calendar for a cpt, using get_calendar or other
wordpress
I hope you were easily able to understand my situation through the question. 1.Do we have any theme or plugin for on-spot editing the post by people or by me after the blog post is posted? 2.If there isn't any theme or pluggin for such feature should I make plugin or theme independently for my website. 3.If both of the...
This is typically called edit in place . Try the Front End Editor plugin.
How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
wordpress
I've managed create a metabox that lets me upload and then fetch the images and then also been able to add jquery ui sortable to be able to sort the images, however I've no idea how to add actual functionality so that the sort order get saved. If someone has an idea how to achieve this or some tutorial that would be he...
To save the menu order use <code> wp_update_post() </code> with each attachment ID and its new menu position: <code> $thisattachment = array(); $thisattachment['ID'] = $thisid; $thisattachment['menu_order'] = $new_menu_position; wp_update_post($thisattachment); </code> EDIT - assuming these are already attachments and ...
Control attachments menu order with jQuery Sortable
wordpress
I am moving an entire site from html and dreamweaver format to wordpress. I imported the content using htlm import plugin that worked well. Now I have to correct all content links as they kept the same variable url format applied by dreamweaver and as I have changed the dite directory structure, most of them are broken...
I would use #2 (/parentpage/page/), since that's the 'official' URL WP assigned to it, WP will find the right page faster and it may help you with your SEO. Yes, if you change slugs it will be a broken link, you could use the Redirection plugin for that (it has the option to add a redirection from the old slug to the n...
Replacing broken urls (dreamweaver) to new ones in wordpress
wordpress
Im using wordpress together with qtranslate and it works on pages and post but not in menus, widgets etc. So i created jquery scripts to solve those issues. The problem is that the field "link_description" in wordpress link section is limited to 30. Using two languages or more, 30 characters is not enough. Is it possib...
First of all, "link description" is defined in the database structure as VARCHAR(255), and I don't think there's anything in core limiting the size of the field farther. Are you sure that you can't fit more than 30 characters in your bookmark descriptions? That said, 255 characters can still be small if you are trying ...
Change maxlength of link_description in dashbord link section?
wordpress
I noticed that when starting to create a new post, and only attach images and then when leavning the post for some reason, it won't show up in the list post view. However when you look in the Media Library you'll see that the image is attached to "Auto Draft" and that the post really exists. Now, I find this useful, an...
try pasting this in your theme's functions.php file <code> add_filter( 'parse_query', 'display_autosave_and_revisions' ); function display_autosave_and_revisions( $query ) { global $pagenow,$typenow; if ( is_admin() &amp;&amp; $pagenow == 'edit.php' &amp;&amp; $typenow == "post") { $query-&gt;query_vars['post_type'] = ...
How to list "invisible" Auto Drafts?
wordpress
Just putting my feelers out on this one, I need to be able to accept incoming emails and add them as posts, however I want to be able to do a bit of processing first, for example I want to change the slug, prepend a string to the title etc. Is there a way I can hook into the email function, change some data and then le...
If you dig into the code of postie (plugin) , you'll probably find your answer. In particular, see the filter sample files, and then trace backwards from there. From the FAQ: Can I add special text to the body of the post when using postie? , Yes. You can create your own function, and use the postie_post filter. Two sh...
Extending post by email
wordpress
I'd like to replace my: <code> if(is_home()) { wp_enqueue_script( 'homestuff', get_theme_part( THEME_JS . '/home.js' ), array( 'jquery' ), null, true ); wp_enqueue_script( 'jquerycolor', get_theme_part( THEME_JS . '/jquery.color.js' ), array( 'jquery' ), null, true ); }; </code> Which is currently in header.php, by put...
First, if you want to target the site Front Page , you need to use <code> is_front_page() </code> . The <code> is_home() </code> conditional returns true when the blog posts index is displayed, which may or may not be on the site Front Page . Second, you need to hook your function into an appropriate hook, which it app...
Wordpress Enqueue for homepage only, functions.php, wp-framework
wordpress
Its that possible?Than when something is added to page in admin panel, page link to that page appears.
I think you would need to implode(',',$excluded_pages) for things to work, <code> $excluded_pages = array(); $all_pages = get_pages(); foreach ( $all_pages as $the_page ) { if ( '' == $the_page-&gt;post_content ) { $excluded_pages[] = $the_page-&gt;ID; } } wp_list_pages( array( 'exclude' =&gt; implode(',',$excluded_pag...
Hide links to pages that dont have any content
wordpress
I'm trying to enqueue a JS script only when someone is adding or editing a custom post type I created called "recipes". Currently the script works ok when I do this: <code> if (is_admin()){ wp_enqueue_script( 'my-script' ); } </code> But this loads it in every admin page, I'm assuming I need to hook it to a function bu...
You can do it like this (put in your <code> functions.php </code> ) : <code> function add_admin_scripts( $hook ) { global $post; if ( $hook == 'post-new.php' || $hook == 'post.php' ) { if ( 'recipes' === $post-&gt;post_type ) { wp_enqueue_script( 'myscript', get_stylesheet_directory_uri().'/js/myscript.js' ); } } } add...
How to enqueue scripts on custom post add/edit pages?
wordpress
Hopefully a basic question, but one that plagues me nonetheless. I have a couple of self-hosted WordPress installs on my website. An issue that I have is that I have common users registered for each site....however some of them feel its a pain to have to go through the signup process each time, and have to juggle multi...
I think WordPress. com is an OpenID Provider , meaning that you can use the OpenID Plugin, and allow users to use their WPCOM account to register/login to your site. As far as I know, WordPress. org is not an OpenID Provider (though that would be a neat idea!).
Allowing WordPress.org/com accounts on a self-hosted install
wordpress
For some strange reason, comments aren't being displayed when a user is not logged in. I've done some extensive experimenting with comments.php without any success. Here's a reference to the example page: http://gycweb.org/by-this-will-all-men-know/ If you are logged in, you would see 3 comments. If you are not logged ...
Toscho was right. I wound up having a query that was getting in the way. It took a bit of troubleshooting to figure out, but I nailed it. If you run into similar issues, look carefully for any custom queries you may have on the template and make sure that you've wrapped them up properly.
have_comments not true for logged out visitors?
wordpress
I created two custom taxonomies (Majors and Seminar Types) related my custom post type CEMB Seminar and the labels on the menu, instead of showing the labels I put in are showing "Post Tags". See a screenshot here (I don't have enough reputation to post pics yet): https://picasaweb.google.com/112518288555484095597/Word...
Try changing <code> 'labels' </code> to an array arg, and passing that. Also, check for syntax: <code> $labels =&gt; array( 'name' =&gt; _x( 'Seminar Types', 'taxonomy general name' ), 'singular_name' =&gt; _x( 'Seminar Type', 'taxonomy singular name' ), 'search_items' =&gt; __( 'Search Seminar Types' ), 'popular_items...
Custom taxonomy labels won't display
wordpress
There're lots of examples both here and on the internet, I've tried but don't seem to be able to achieve what I need although it does feel like it should be simple enough. Basically, I want to be able to use a shortcode like this: <code> [download]http://site.com/file.doc[/download] </code> and I need Wordpress to outp...
<code> // Declare your shortcode add_shortcode("download", "downloadFunction"); // Second Declare your shortcode function function downloadFunction($att, $content, $code){ // your function is passed 3 Arguments // $atts : this is an array of the shortcode's attributes // $content : this is the content between the code....
Create a shortcode in Wordpress, again
wordpress
Right now I'm using a code in the functions to override the default WordPress gallery CSS. But it seems for some reason that WP only wants to let me put 3 images per line in a gallery, despite my CSS. Anybody know how to fix this? My problem can be found here -> http://themeforward.com/demo2/features/gallery-2/ and my ...
You have to account for all appropriate CSS classes, based on the number of columns passed to the shortcode. Here's my CSS (borrowed heavily from Michael Fields), for handling from 1 to 10 columns: <code> .gallery { margin: 0px auto; text-align: center; width: 100%; min-width: 100%; } .gallery .gallery-item { float: le...
Gallery CSS Problem
wordpress
There are certain posts on the website I'm developing, that don't need the author(s) by-line. (such as press releases) Is there any method, that allows me to remove the author (and co-authors) for certain posts?
Thanks to mike23's suggestion, I solved my problem with conditional tags. Just insert the following in the author area of <code> single.php </code> , <code> archive.php </code> and any other page template that displays an author. <code> &lt;?php if ( has_tag('press_releases') ) { echo ''; } else { echo 'by '; the_autho...
How To Remove The Author(s) From Certain Posts
wordpress
My site has Facebook social graph meta tags in its page: <code> &lt;meta property="og:title" content="First Look at Dwarves from The Hobbit"/&gt; &lt;meta property="og:description" content="Movie"/&gt; </code> The only Facebook-related plugin I have installed Facebook Page Publish . Why is it only picking up the catego...
The Facebook Page Publish plugin is adding the og:description. Looking through the code in fpp_index.php at lines 843 - 851: <code> $description = array(); if ($options['show_post_author']) { $description[] = esc_attr(fpp_get_post_author($post));/*, ENT_COMPAT, 'UTF-8')*/ } if ($options['show_post_categories']) { $cate...
What is generating my meta og:description?
wordpress
is it possible to create a loop of posts using WP_Query or query_posts using the title? ie <code> $args = array('post_title'='LIKE '.$str.'% '); $res = WP_Query($arg); // the loop... // trying this now... $mypostids = $wpdb-&gt;get_col("select ID from $wpdb-&gt;posts where post_title like 'Abb%' "); echo count($myposti...
got this working with the help from this post in the end. Cheers guys; <code> $finalArgs = array ( 'posts_per_page'=&gt;5, 'order' =&gt; 'ASC', 'post_type' =&gt; 'school' ); // Create a new instance $searchSchools = new WP_Query( $finalArgs ); $mypostids = $wpdb-&gt;get_col("select ID from $wpdb-&gt;posts where post_ti...
query_post by title?
wordpress
What is the best way to modify a plugin? I frequently want to make small changes to one or two functions within a large plugin. This is easily done, but I have to use comments to mark my changes and modify the plugin again after an update. Ideally I'd like to leave the plugin alone and make my changes elsewhere, much l...
IMHO, the best approach is either to fork the Plugin to maintain your changes, or else submit patches to the Plugin developer, to have your changes made a part of the original Plugin. Creating a "Child Plugin" really isn't easy. The "Child Theme" concept really applies to the template files that get used, moreso than t...
Proper Way to Modify Plugin
wordpress
Function to list all post slugs for every post in wp_posts table? I assume there's an official function to generate a post slug, but maybe someone here already has the answer.
example - unordered list with post slugs: <code> &lt;ul&gt; &lt;?php foreach( get_posts('numberposts=-1') as $post ) { echo '&lt;li&gt;' . $post-&gt;post_name . '&lt;/li&gt;'; } ?&gt; &lt;/ul&gt; </code> http://codex.wordpress.org/Template_Tags/get_posts
Function to list all post slugs for every post in my WP database?
wordpress
I'd like to prevent certain user roles from accessing the dashboard http://www.openeye.net/wp-admin/ at all. I've moved and restyled user profiles to a new page that's viewable on the site. How would I go about doing this?
To lock subscribers and contributors out of the admin: <code> function wpse23007_redirect(){ if( is_admin() &amp;&amp; !defined('DOING_AJAX') &amp;&amp; ( current_user_can('subscriber') || current_user_can('contributor') ) ){ wp_redirect(home_url()); exit; } } add_action('init','wpse23007_redirect'); </code> Hope that ...
How do I remove dashboard access from specific user roles?
wordpress
I want to get the page content (so i can parse the tags/short-codes in it), but i don't want to output the result itself to the browser (i.e. echo=0). I tried get_the_content(); but its the same deal.
Where are you doing your code parsing? If you're doing it directly in the template file, inside the Loop, then you should be using <code> get_the_content() </code> . However, it might be more efficient to filter <code> the_content() </code> , via the <code> the_content </code> filter. e.g. in <code> functions.php </cod...
Get the Page Content,without generating HTML
wordpress
Well, i'm creating a wordpress theme, but i can't get wordpress loop to work correctly for some reason. This code works fine in index.php : <code> &lt;?php if (have_posts()) : while (have_posts()) : the_post(); var_dump($post); endwhile; endif; ?&gt; </code> But, it does not work in my blog.php page(it's not a template...
Within your blog.php file you need to declare <code> &lt;?php wp_head(); ?&gt; </code> without this the loop will not work and only so many items within <code> $post </code> will be available to you.
Wordpress loop not working on blog.php page
wordpress
When creating a new network site, by default the site option <code> Uploads Use Yearmonth Folders </code> is on (set to <code> 1 </code> ). I have to set it to <code> 0 </code> each time I create a new site. This isn't horrid, but is it possible to make this the default for newly created sites? Perhaps a hook or someth...
You could just change the option after the blog is created: <code> add_action('wpmu_new_blog', function($blog_id){ switch_to_blog($blog_id); update_option('uploads_use_yearmonth_folders', false); restore_current_blog(); }); </code> Drop this code into a .php file inside wp-content/mu-plugins
How can I have network sites not use year/month folders by default?
wordpress
I have installed XAMPP to build a site on localhost. After I finish, how do I transfer everything efficiently to, say, a client's server?
See Moving WordPress « WordPress Codex and Backing Up Your Database « WordPress Codex and How to Move WordPress Blog to New Domain or Location » My Digital Life and possibly Giving WordPress Its Own Directory « WordPress Codex Deleted this added link as it advocates using a texteditor to change URLs in the dump; that w...
After finishing building a site on localhost, how do I transfer everything to a client's server?
wordpress
I have a widget <code> class Xwidget extends WP_Widget{ function cron_addB(){} } </code> I want to run a cron job that calls that function from outside the class <code> function xxx_cron_activation() { ; if ( !wp_next_scheduled( 'xxx_followers' ) ) { wp_schedule_event(time(), 'hourly', 'xxx_followers'); } } add_action(...
Try this instead: <code> $gloabl $myxclass; $myxclass = new Xwidget(); add_action( 'xxx_followers', array(&amp;$myxclass, "cron_addB" ) ); </code> or <code> add_action('xxx_followers', "init_xclass_and_cron"); function init_xclass_and_cron() { $myxclass = new Xwidget(); $myxclass-&gt;cron_addB(); } </code>
Calling static method in the Widget Class
wordpress
I've built a small widget for my website It has a couple of inputs, and a <code> &lt;textarea&gt; </code> among others. Whenever someone inputs to the textarea it adds a tab at the begining and changes every ' to ' After a couple of times I save the same input, I just get sentences that were It's nice to It\\\'s nice t...
Try stripslashes to remove the backslash. <code> echo stripslashes( $text ); </code> This is going to replace one slash per slashes group only though, you should first reset all the contents that have multiple slashes. I guess the tab at the beginning is due to the fact that you jump a line before echoing the text. Try...
Widget textarea input gets formatted
wordpress
is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the rest of imgs only render into hidden img tags (will be visible through lightbox slideshow). So is there any function lik...
You can use <code> get_posts() </code> ( Codex ref for getting Post attachments ). <code> &lt;?php $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -1, 'post_status' =&gt; null, 'post_parent' =&gt; $post-&gt;ID ); $attached_images = get_posts( $args ); ?&gt; </code>
How to get Images included in Post
wordpress
I have a custom post type, I am echoing out my custom taxonomies in my template by doing the following, <code> get_the_term_list( get_the_ID(), 'work', '&lt;li&gt;', "", '&lt;/li&gt;') </code> , this currently returns "Design", what I am wanting to do, is the following, for the first value that it is found I want to do...
I would use <code> wp_get_object_terms </code> which will return an array of object terms that you can manipulate. You also have a little more control with sorting the terms. <code> &lt;?php $terms = wp_get_object_terms($post-&gt;ID, 'work', array('orderby' =&gt; 'name', 'order' =&gt; 'ASC')); if(is_array($terms)) : ?&...
get_the_term_list() wanting to loop through the returned values
wordpress
I want to get a sidebar and save it in a Variable, This is impossible with the get_sidebar function since it simply prints out the sidebar, is there another function that I can use?
You probably need to use output buffering , if I understand your question correctly. Try something like this: <code> ob_start(); dynamic_sidebar('sidebar-id'); $sidebar = ob_get_contents(); ob_end_clean(); </code> That will put the output of the sidebar into the variable $sidebar, which you can then process and return ...
how do I get_sidebar into a varaible?
wordpress
I'm using this in a file named category-portfolio.php which is for the archives page of my portfolio. I don't want to use cat= to specify a specific category. But when I don't use cat= it pulls up every post regardless of category. How do I make this code pull up only the current/relevant/portfolio category? Thanks a m...
The problem is that your call to query_posts is overwriting the original query for the page. You have to get the original query, then modify any params from there. <code> global $query_string; // start with the original query $myquery = wp_parse_args($query_string); // make any changes to the query here $myquery['posts...
Call Current Category
wordpress
I am trying to call in all posts in the current category, showing their thumbnail or 'featured image'. The code below does not work, it throws out a syntax error... <code> &lt;?php $temp_query = $wp_query; ?&gt; &lt;?php foreach(get_the_category() as $category) { $cat = $category-&gt;cat_ID; } query_posts('orderby=date...
the two single quote marks (after the number 1) in this line (of the top posted code section) seem to be causing the error - there should only be one single quote; shown below: <code> query_posts('orderby=date&amp;cat=' . $cat . '&amp;order=ASC&amp;posts_per_page=-1'); </code> it is just puzzling that your other code (...
query_posts thumbnail condition
wordpress
Is there a reliable plugin that I could use to automatically backup the WP database? It's really important that it's just the database and not the files. I'd like it to automatically download a copy of the database and store it on my computer in a specified file. Is there one out there that could do this?
BackWPup has a lot of flexibility in timing, what to backup (down to the DB table level), and it can store to DropBox which would put it on your computer.
Plugin for automatic database backup?
wordpress