question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I have a front end post form that I'm having some problems getting the right path for the media to save as custom fields. The path to the file gets saved as mysite.com/home/betauser/public_html/betatheme/wp_content/....file path. How do I get the path to save correctly? <code> &lt;?php if( 'POST' == $_SERVER['REQUEST_M...
For starters, the 'post_category' argument only accepts category ID's, so you will have to find that through your database, or through get_category_by_slug: <code> $cat = get_category_by_slug( 'music' ); $cat_id = $cat-&gt;term_id; </code> Secondly, look at your wp_handle_upload() section. You are passing $file['file']...
Problem uploading different files as custom fields with front end post form
wordpress
I am looking for a solution/guidance on how I might have links of posts listed in a hierarchical manner in a left column of a template and when a link is chosen it loads a post in the right column but the whole page does not refresh? Thanks, Deon Update for Marfarma's help below Thank you for the response. After readin...
Here's how I'd approach it. Let me know in the comments if you need more detail. 1) Create a template that pulls back your initial page content -- the default right panel content and the list of links for the left panel. Ensure the links have post_id set as the value of the id attribute. 2) Write a Javascript request f...
Load posts dynamically
wordpress
I have been attempting to build a plugin(my very first) that adds some functionality for use with the Custom Header admin screen. I would like to have my plugin add an anchor link to the Appearance > > Header admin screen, and have the link trigger a function in my main plugin file: but, I'm having a lot of trouble fig...
Ok, after a bunch of stabbing in the dark, I have successfully added a link to the Appearance > > Header admin screen: and, when clicked on, the link triggers a jquery .post() ajax request that calls a function in my main plugin file. I am going to share a basic example of what I did so as not to divulge my secret plug...
Modify a Themes Appearance > > Header admin screen from a plugin
wordpress
Is there a way to do normal links in WordPress (not image source links) in a "relative" manner?? Im doing custom site in WP and some portions of the site, for example an image link that when clicked, leads to a specific dynamically built WordPress page, i always link them absolutely. So for example, if the website word...
There's a couple of things that you might be able to do here depending on how you are creating your links. Are you talking about page content or are you working in the theme template. If in the theme template you can do use the <code> &lt;?php bloginfo('url'); ?&gt; </code> to get the base path of the blog. That will c...
WordPress relative links for regular non image links
wordpress
I'm trying to build a complex search form with filters for several custom taxonomies, a search terms input and a select for the number of items displayed / page. The question has been posted before over at stackexchange-url ("Advanced search form with filters for custom taxonomies and custom fields") and the answer pro...
The reason you are losing your filters is because you are passing them through POST in the forms. This is fine, but you will have to store these values somehow for the pagination. I believe if you used GET, you may retain the values on "page 2", but any POST values are lost as soon as you go to the next page. You could...
Advanced search form with filters for custom taxonomies
wordpress
Is there a save_post hook for custom post types? example: save_my_post_type I know there is publish_my_post_type but I'm looking for a save hook.
the hook is the same <code> save_post </code> just make sure its your post type ex: <code> add_action('save_post','save_post_callback'); function save_post_callback($post_id){ global $post; if ($post-&gt;post_type != 'MY_CUSTOM_POST_TYPE_NAME'){ return; } //if you get here then it's your post type so do your thing.... ...
Save_post for custom post type?
wordpress
This is the code I am using: <code> &lt;?php echo str_replace( home_url(), '', get_permalink($post-&gt;ID) ); ?&gt; </code> What it does is output the permalink as a relative URL i.e. only the slug. For instance, if the permalink is <code> http://example.com/2012/01/post-title/ </code> , the relative URL output by the ...
Use <code> $_SERVER['REQUEST_URI'] </code> instead of <code> get_permalink() </code> to grab the current URL. e.g. for example.com/test/page <code> echo $_SERVER['REQUEST_URI']; </code> prints <code> /test/page </code>
Get Permalink without domain (i.e. get relative permalink)
wordpress
I get these warnings after getting live with my wordpress site from local to server. <code> Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'bones_register_sidebars' not found or invalid function name in /is/htdocs/wp1108989_5IDG6XP7VR/www/cgi-bin/website/wp-includes/plugin.php on l...
These are warnings, not errors ( edited original question to reflect this ). You have two options: The easy way - Turn off displaying errors and warnings, log them to a file instead The proper way - Fix the warnings, and log them to a file instead of outputting If you need help fixing the warnings, post your code I'll ...
warnings & errors after MAMP to live (hosteurope)
wordpress
Got an alert on my adsense account which says You have rejected ad requests, which will result in lost revenue. The following ad units have made ad requests with incorrect site information. This occurs when the URL of the server from which the ad unit has been served differs from the URL of the actual page where the ad...
Do not change your AdSense ad code because of this rejected ad requests issue! This is a system glitch that Google will correct. Google has recognized and added the issue to their “Known Issues” list with the following description: “Some accounts incorrectly notified about rejected ad requests” We recently changed the ...
Adsense: You have rejected ad requests, which will result in lost revenue
wordpress
I'm working on a theme homepage and would like to include an excerpt from the latest post in a specific category. In this case, the category slug is "gear". I've tried a couple options with <code> WP_Query </code> but am unable to get it to return only one post. Here's my current code: <code> &lt;?php $latest1 = new WP...
Try this: <code> $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query("category_name=$catName&amp;paged=$paged&amp;posts_per_page=1"); </code> Basically, add the paged variable to the args -- since it's your home page, you could hard code it to equal 1, of course.
How to get latest post excerpt from a specific category?
wordpress
I have a wordpress multisite. I'm using a single domain, but I want to use multiples domains. I want to allow the user choose a domain for his subdomain. I was searching, but i don't found nothing about this... only a domain mapping plugin and is for singles sites.
One way to do it is to use the Networks for WordPress plugin: https://wordpress.org/extend/plugins/networks-for-wordpress/ It will create a sub-network for each of your domains. So basically you'd have a network of networks of sites. Each sub-network will be using the same install of WordPress, but will be managed sepa...
Multisite multidomain
wordpress
I am trying to use categories to provide the structure for my site. I will create sections on my site called England, Wales, Scotland and Ireland . These will be categories. My posts will use custom post types - Video, Guide, Event, Clubs etc. So, if I create a post called 'Trouble down south' using the 'Video' CPT, at...
You have to filter <code> 'post_type_link' </code> to create the appropriate permalink. See stackexchange-url ("this answer") for a similar example. The following code works: <code> add_action( 'init', array ( 'WPSE_63343', 'init' ) ); class WPSE_63343 { protected $post_type = 'video'; public static function init() { n...
How to achieve this permalink -> category-name/custom-post-type-name/post-name
wordpress
I am trying to remove the title from all my category and tags page. So far, I have been using this code http://pastebin.com/xxmyw7BP . It works but not perfectly. The title of my category and tag page is removed. However, on my sidebar, the content in my recent posts widget also lose their titles. What other qualifier ...
I agree that editing the loop would be the best way to do this as it keep the changes local to that php template. Simply go into category.php (or archive.php) and tag.php, look for <code> &lt;?php the_title(); ?&gt; </code> and delete it or change it to <code> &lt;?php //the_title(); ?&gt; </code> to comment it out.
How to Remove a Title from All Category and Tags Page?
wordpress
I am working over a wordpress website which is basically a union of wordpress + their official website which is in php. In wordpress I am simply showing wordpress data. but when user need to create something , then user is directed to that official website. Example 1. Create new flower from the flower page (I have cont...
I'm not completely sure what you mean but if you're wanting to keep all the links represented in the Wordpress system you could use the 'page links to' plugin and create a Wordpress page for each of the external links - http://wordpress.org/extend/plugins/page-links-to/ Then link to the Wordpress page version from with...
multiple external urls in wordpress website
wordpress
I have several images that are wider than they are tall (landscape). The problem is that the theme I'm using crops images to 150x214px (taller than they are wide). This set up works for the majority of the images but there are still several left with the sides cut off. Is there anyway I can mass-crop the images that ar...
In media settings change: Crop thumbnail to exact dimensions (normally thumbnails are proportional) to unchecked. This will fix the problem on new images. For old already imported images, you'll need to regenerate them. There are many plugins that can do this. This plugin is well known: http://wordpress.org/extend/plug...
Mass crop images: Landscape images -> Portrait images
wordpress
I have the selected option saved correctly, but when load the page, wp_dropdown_categories still load the list by its order. I prefer to load the selected item on top. How to do this?
if the currently selected item has some type of identifier on it (maybe class="current") you may be able to use some jquery to grab it's value, hide it, then move it to the top. <code> &lt;div class="topdiv"&gt; this is top div &lt;/div&gt; &lt;ul&gt; &lt;li&gt;1&lt;/li&gt; &lt;li class="current"&gt;2&lt;/li&gt; &lt;/u...
How to make wp dropdown category load with selected option on top?
wordpress
I need to do some query. Now i choosing from this variables. Which is from this queries is more faster. Which differences between them ? <code> function filter_where($where = '') { $where .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-10 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where');...
These queries are the same - the only difference being the syntax. There'll be no noticeable performance difference. I prefer the first for readability when it is formatted correctly. (Also, the first query doesn't use the <code> paged </code> argument, so it won't 'paginate' - but I guess that was omitted by mistake).
Which is from this queries is more faster
wordpress
What I had was normal posts...until I realized that custom posts are what I should use for my purpose. But then I noticed that I don't have the option to make a custom post sticky from the admin panel. Is there a way to get that feature working?
there was a big talk about that : http://core.trac.wordpress.org/ticket/12702 They ended deciding that a custom field will have to be used...
how to make custom posts sticky?
wordpress
I've created a Plugin which adds a new meta-box on the post.php dashboard page, containing a form. Whenever a POST request is submitted from that form, I would like to save some post meta-data. I have been able to implement this, but I noticed that each time this POST request is sent, the entire blog post gets updated,...
The metabox itself sits inside a form which encompasses (almost) the entire page. You're metabox callback shouldn't print a form itself (since you'll end up with nested forms). Instead the meta data should be updated when the post itself is updated, using the <code> save_post </code> hook. The only way of updating part...
Avoid updating post when sending POST or GET request to post.php
wordpress
I installed ThreeWP Broadcast through the WP backend and it works fine. But where can I find the associated PHP files? I've tried looking in the plugins and mu plugins folder of wp-content.
Go on your plugin list and hover the edit button for the selected plugin. Have a look at the url. It should be something like: <code> http://&lt;domain&gt;/wp-admin/plugin-editor.php?file=&lt;path-to-plugin&gt; </code>
Plugin activated but plugin files nowhere to be found
wordpress
In a post, I have this text: <code> [bhours shortcode="test" title="test"] </code> But the "title" attribute appears to be ignored. Here's a var_dump of the $atts attribute array <code> array(1) { ["shortcode"]=&gt; string(4) "test" } </code> Here's the PHP code: <code> function bhour_shortcode_handler($atts){ global $...
I figured out the problem. I had a function that was stripping the title attribute from the HTML, but couldn't differentiate between a shortcode and an HTML tag. So, I converted over from regex to DOMDocument. stackexchange-url ("stackexchange-url
Shortcode attribute "title" doesn't appear in $atts array
wordpress
I have multiple sites setup within my site. I need to access all the various options tables which are named 'wp_#_options'. How can I select these tables that have a number prefix? Using <code> $wpdb-&gt;get_results($wpdb-&gt;prepare("SELECT * FROM ".$wpdb-&gt;7_options." WHERE .....")); </code> gives me a parse error.
When in multisite, the wpdb prefix is always the prefix required to access the tables for the current site. This includes the site ID so this should work: <code> $wpdb-&gt;get_results($wpdb-&gt;prepare("SELECT * FROM ".$wpdb-&gt;prefix."options WHERE .....")); </code> There should be no difference at all when using mul...
Access Tables with number prefix
wordpress
Please help! I have a form for users to submit posts, and I want them to be able to choose photos already in the media gallery based on category selected. I want to include radio buttons to choose between a few images that will attach to the post, become the featured image, or just echo out in a template file in this m...
I got custom fields working in the front end form linked in this post: stackexchange-url ("How to use nonce with front end submission form?") Here is the code used for the form page (custom page template): http://pastebin.com/YWyXL3jY Hopefully that will be of help to you with a bit of tweaking to use image URL's inste...
How do I insert a custom field in a user submitted post?
wordpress
I need to get the topmost term (top level ancestor) of a taxonomy term. Suppose the following term hierarchy: <code> North America United States New York New York City South America Mexico </code> I need to get the ID of "North America" term if I know the ID of "New York" I'm using an adapted function found on stackexc...
I guess this function is what you are looking for -> get_ancestors()
How to get the top most term (top ancestor) of a custom taxonomy child term?
wordpress
Is there any plugin that can immediately return a site to how it looked when just installed, including removing all extra db entries, themes and plugins installed etc?
The WordPress Reset plugin will reset your database to its default settings. This plugin doesn’t delete files, so you’ll have to manually delete themes and plugins before using this plugin.
Plugin that resets database and deletes all content, plugins
wordpress
I wrote a plugin that creates a custom post type with custom fields. To prevent users from entering incorrect information, how can I validate the data? I assumed that the save_post hook function would process field validation, but I can't seem to find a straight forward way that displays errors back to the user. Is the...
You're on the right track. I test the fields in the <code> save_post </code> callback, and then use admin notices to display errors to the user when a field fails validation. They show up just in a highlighted box at the top of the page, just like any errors/messages that WordPress itself generates. Here's a simple exa...
How to validate custom fields in custom post type?
wordpress
I have 3 loops on one page, each pulling a different CPT into a portfolio like layout. Live: http://iassc.baltimoredrew.com/providers/ Gist: https://gist.github.com/3503334 However the tags for the second and third sections are inheriting the ones from the loop before it. Also when I click on one of the tags to filter ...
Pretty simple fix, from what I can tell.. after each "loop" you need to reset your term list.. <code> $term_list = ''; </code>
Loops running into each other
wordpress
How can I output ONLY the post content (ie the text entered into the wysiwyg) and nothing else? i just need this for the posts in a specific category, so if i could call like say, <code> &lt;?php get_template_part( 'venue_content', 'single' ); ?&gt; </code> it would be ideal.
Assuming you are in the loop, or otherwise know (or know how to get) the <code> $post </code> object: <code> function wpse63358_get_post_content() { global $post; return $post-&gt;post_content; } </code> If you want the formatted post content, replace this: <code> return $post-&gt;post_content; </code> ...with this: <c...
How to output only the post content
wordpress
I am working on a site and am having an issue with one of the categories. There is plenty of content on the site and there are seven different categories. All of the categories display the correct posts except for the very last one. I've searched all around and have not seen this exact issue come up (oftentimes, people...
The problem is almost assuredly your custom loop. I am guessing that this is your problem: <code> $category = get_the_category($post-&gt;ID); $category = $category[0]-&gt;cat_ID; </code> Further, I'm guessing that the <code> $post </code> object being queried here has more than one category term defined. Thus, <code> $...
Archived Posts in Wrong Category
wordpress
I am trying to create a custom theme using Wordpress 3.4's customization options. I would like to create an option to change the theme's logo, but I would like to also display a default logo image. I am using the following code in my function.php page: <code> $defaultbranding = "get_bloginfo('template_directory') . '/i...
I had the same problem a few minutes ago. Here is what I used in the src tag: <code> &lt;?php if (get_theme_mod( 'custom_logo_image' )) : echo get_theme_mod( 'custom_logo_image'); else: echo get_template_directory_uri().'/inc/images/default_logo.png'; endif; ?&gt; </code> It seemed to solve my problem. Let me know if i...
wp_customize_image_control default value
wordpress
From a default WordPress install, I have set a static page as the front page and now I want to have the last posts (what is normally seen when visiting the root of the website) in a "Blog" page. Do I have to create a special template for this page where I must create a new query, save the paged variable for the navigat...
When changing the setting to make the front page a static page, you will have assigned the blog posts to another page. If you name that page 'blog' you can access your latest posts at yourwebsite.com/blog No extra tinkering required :)
Move Index to a page
wordpress
I need to build a "export as .csv" functionality into my plugin. Problem is: i get the header already sent warning, because by the time my "export" function is called, Wordpress has already started rendering. The way i set it up is via a small form in the Settings screen, which action attribute points to a file (downlo...
The start of what you're doing wrong can be explained by this quote: which action attribute points to a file (download.csv.php) in my plugin folder, that should not be shown, just prompt a file download dialog for the csv dump. and this code: <code> $core = $_POST['download'].'wp-load.php'; if(isset($_POST['download'])...
export csv functionality into my plugin
wordpress
I have a custom post type <code> bhour </code> , with a field <code> bh_shortcode </code> . When a post of this type is saved, I'd like it to add a shortcode based on the post's value of <code> bh_shortcode </code> . If the value of <code> bh_shortcode </code> is "test", and when a [test] shortcode tag appears on a nor...
Just use as per the following code sample in your plugin., <code> function wp_shortcode( $atts ) { extract( shortcode_atts( array( 'foo' =&gt; 'something', 'bar' =&gt; 'something else', ), $atts ) ); //return "foo = {$foo}"; return your_function(); } add_shortcode( 'your-shortcode', 'wp_shortcode' ); </code> I think th...
add_shortcode() not working inside of function
wordpress
i would like to show the submenu of my page in a custom page template on the left side in a Sidebar-area. Does any know the code for showing the submenu. Wordpress 3.4.1 Thanks a lot!!!
If you are trying to code this yourself, all the info you need is in the Wordpress Codex - http://codex.wordpress.org/Template_Tags/wp_list_pages#List_Sub-Pages Alternatively you could use a widget like the BE Subpages Widget
Submenu in sidebar custom page template
wordpress
I've setup a post type-Product with custom fields containing price and other attributes. I'm reading Paypal Documentation right now, What i've read till now is "HTML-Buttons" can be pasted from Paypal, but i can't tell my client to copy and paste the "Add to Cart" button from Paypal every time he creates a new product....
You can create a custom template in the theme that displays the 'products' custom post types (see the section on Template Files in Custom Post Types ). Then code the HTML for the Paypal button in to your specific <code> single-{posttype}.php </code> and have the attributes such as price, etc, coming from custom fields....
Add Paypal Button programmatically
wordpress
Given the following the following products: product 1 Naam part of taxonomy "brand" value "Joolz" part of taxonomy "Categorie" value "Chair" product 2 Naam part of taxonomy "brand" value "Joolz" part of taxonomy "Categorie" value "Car" product 3 Naam part of taxonomy "brand" value "Costa" part of taxonomy "Categorie" v...
Start with a <code> tax_query </code> to get posts with the <code> 'categorie' </code> taxonomy term you want. Assuming a custom query: <code> $tax_query_args = array( 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'categorie', 'field' =&gt; 'slug', 'terms' =&gt; array( 'costa' ) ), ); $tax_query = new WP_Query( $tax...
Semi complicated custom taxonomy question
wordpress
I am following the tutorial here http://wp.tutsplus.com/tutorials/creative-coding/creating-a-simple-backuprestore-settings-feature/ The script shows how to export all options into JSON. Since my plugin creates a custom post type, I would also like to export and import all posts of this custom post type. How can I do th...
There are two basic approaches you can take. Use the standard wordpress inport / export plugin manually through the admin. Your custom post type must have the property can_export = true (default = true) If you go this route, there are interesting options for adding extra functionality for users, Check out this tutorial...
How to Create Export/Import Functionality for Plugin
wordpress
Can anyone tell me if there is anywhere I can find out what each of these TinyMCE plugins are for? <code> $in['plugins']='inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen'; </code> I'm wondering because if I remove the <code> wordpress </code> one that the edito...
The first few you listed are not WordPress specific, and information about them can be found as follows: inlinepopups tabfocus paste media fullscreen As for the WordPress specific plugins, their source code is here (trac) . There are no comments, but here's my take based on a very cursory read through: wordpress: seems...
TinyMCE Plugin Parameter
wordpress
I am on a shared hosting on HostGator and now I want to take one other shared hosting on some server and want to put only the images used on my site to it. So that those http requests of images could go to another server, is that possible? and how? thanks.
What you are looking for is called "CDN" or "Content Delivery Network". Here is a WIKI ! definition if you are not familiar. There are plenty of good tutorials out there that will show you how to carry this out using Wordpress. Here is one you can have a look at. http://www.cyberciti.biz/tips/wordpress-cdn-content-deli...
Different Server for Images
wordpress
I have a bit of javascript that will dynamically add a static post to a loop. The script uses the jQuery 'after' method and on a static page it works beautifully but when inside the loop I don't get any results. Can anyone see what i'm doing wrong here? Does WP not allow DOM insertion within a loop? <code> function new...
WordPress requires no-conflict for jQuery . Change this: <code> var tiles = $('#article-tile:nth-child('+adLoc+')'); $(tiles).after(adTile); </code> ...to this: <code> var tiles = jQuery('#article-tile:nth-child('+adLoc+')'); jQuery(tiles).after(adTile); </code> Or else wrap your entire script accordingly: <code> jQuer...
Using jQuery .after inside loop
wordpress
I recently installed WordPress on my own server, which uses non-port 80 Apache service. I could view posts but the tinymce editor constantly broke. More specifically, all menu items in visual editor did not appear and if there were any text, they were all invisible until I highlighted them. After numerous research, som...
I had exactly same issue with Visual Editor but my site was working on port 80. This is what I did : Edited wp-config.php and added the following : <code> define( 'CONCATENATE_SCRIPTS', false ); </code> and everything worked fine. Additionally you can check if <code> wp-includes/js/tinymce/wp-tinymce.js.gz </code> file...
Wordpress visual editor broke due to non standard port?
wordpress
I’ve put the class for 'logged_in_as' into another container to display the content in another column: <code> &lt;div id="content-form"&gt; &lt;?php $fields = array( 'author' =&gt; '&lt;div class="right_col"&gt;&lt;p class="comment-form-author"&gt; &lt;input id="author" name="author" type="text" value="' . esc_attr( $c...
You don't change the ordering, essentially. If you need to reposition things on the page, you should use CSS. That's what it's for. The submit button is in a P with a class of form-submit. You can use that to move it around with CSS.
How to change the order of elements in comment_form()
wordpress
I'm trying to come to an accurate decision here about safe ajax requests from a template. The thing about AJAX that always scares me is that the called script location is public: <code> http://www.mydomain.com/wp-content/themes/mytheme/inc/myscript.php </code> I just don't feel comfortable with that kind of public know...
Security through obscurity isn't a good pattern to follow. You have to have a URL to make XHR or JSONP calls. Anyone who knows anything about searching the DOM using developer tools, Firebug, etc... can easily find your remote script URL. To me, this is the wrong question to ask. The more relevant question to security ...
AJAX requests within templates
wordpress
I am trying to use a custom value to be used in the author posts URL instead of the <code> user_nicename </code> which defaults to <code> user_login </code> in the pretty permalink structure. So far I managed to do that but now the new URL <code> /author/custom_user_nicename </code> generate a 404 error while the old o...
You'll need to add a rewrite rule as well as the filter you have written. At the moment your filter only changes what is output when the <code> author_link </code> function is called, not WordPress' permalink structure.
Change the author posts link using custom user metadata
wordpress
I have HTML5 Template with 5 pages. I am converting it to a WordPress Theme . I have a contact page. This page includes 'forms.js' script to send contact form data to 'MailHandler.php' file. Inside the 'forms.js' script there is a variable I want to change, <code> mailHandlerURL:'bat/MailHandler.php' </code> How do I c...
If you want to send the url of the website, or other server side calculated values, to JavaScript you can use <code> wp_localize_script </code> ( Codex Page ). This function creates an object, with the values you've passed. As the documentation states, you've got to include your script with <code> wp_enqueue_script </c...
Setting Variable Path to Template Directory inside Script
wordpress
I have this part of code: <code> return '&lt;img class="myimage '.$text_color.' '.$horizontal.$slide_fitscreen.'" src="'.$image.'" alt="" '.$slide_desc.' /&gt;'; </code> What I want to do is to return also a php shortcode but not inside the img element, because my shortcode generates a a element so I need to return it ...
Do not call do_shortcode() </code> . Use the associated handler instead. And if you want to call the shortcode without parameters you have to make the parameters optional in the handler’s declaration: <code> function custom_slidessc($atts = array(), $content = null) </code> So what you need is: <code> return '&lt;img&g...
add php shortcode in return function
wordpress
I've added my own function to save_post as follows: <code> add_action( 'save_post', 'save_recipe' ); function save_recipe( $post_id ) { // ... set $thumb_id from custom code ... set_post_thumbnail($post_id, $thumb_id); } </code> Now if I check my DB, nothing is set for the field <code> _thumbnail_id </code> inside the ...
I was trying to set the Core post-thumbnail. I found my issue. I was running the function: <code> delete_post_meta($post_id, '_thumbnail_id') </code> , before I would <code> set_post_thumbnail($post_id,$thumb_id); </code> Apparently even though the delete was in the code before it still caused it to delete it from the ...
Using set_post_thumbnail inside save_post action gets overwritten
wordpress
I've recently been trying to create a 'Popular Products' widget for for WP e-Commerce. Since there isn't built-in functionality, I referred to Dave Mackintosh's post here and gave it a shot. Still no success. But since there's a shortcode, I decided to use the 'Shortcodes in Widgets' plugin and place the shortcode in a...
This behavior is being caused most likely because something in the shortcode function that is causing unstable behavior. I recently just had the same issue with something I was working on. From the WordPress Codex for "Add ShortCode" there's a note tucked down near the bottom of the page: Note that the function called ...
Widget content turns up before title
wordpress
I just created a new WordPress site in my server. Normally, WordPress uses MyISAM as the database type. But this time, it created all InnoDB tables! Is this normal? Has WordPress switched to InnoDB in the latest versions?
WordPress actually specifies no table type in the create statements, so it uses MySQL's default table engine which is InnoDB from version 5.5 onwards.
WordPress use innodb by default?
wordpress
I just found my '.htaccess' file has the same lines of code repeated twice as below, maybe some plugins changed it, is it incorrect? Should I remove the repeated one? Thanks!! <code> &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteC...
This often happens when using a plugin like WP Super Cache or W3 Total Cache that need to add things to the .htaccess file. You can safely delete the top version (the one without the <code> BEGIN/END WordPress </code> lines), but having duplicate entries won't hurt anything. It will add a tiny bit of overhead as the ru...
Please Check this '.htaccess' File
wordpress
I have created a custom post type; the content of this custom post type should be a full html page - not just a snippet of html. The standard editor appears to interfere with the html and it does not appear to be ready to handle a full html page source as its content. Ideally, I would love to be able to disable the 'ed...
The Problem It seems that you're using the normal theme template files for posts and pages to display your custom post type. This means, that you also got the <code> wp_head() </code> hook and other template, that output default (post/page specific) things. The solution Add a template file to your theme, that's named <...
How can I create an alternate full-HTML editor for posts?
wordpress
I have a theme installed which automatically generates differnet sizes of images (thumbnails) when I add a "featured" image in a post. supermuc-106x80.jpg supermuc-116x80.jpg supermuc-150x100.jpg supermuc-150x150.jpg supermuc-290x180.jpg supermuc-300x174.jpg supermuc-600x250.jpg supermuc-600x400.jpg supermuc-905x500.jp...
Check out @Otto's plugin Dynamic Image Resizer . I think it does exactly what you're asking for. I haven't used it before, so I can't vouch for it, but the plugin author's identity goes a long way toward me trusting it.
prevent wordpress from creating thumbnails of an image
wordpress
Currently I have a short that embeds a div into the the_content. This works fine like thus: [shortcode param=1 param=2] This returns a message at the end of the post, but within the current article, however instead of being: <code> &lt;article&gt; &lt;div&gt; &lt;/article&gt; </code> I'm looking to produce: <code> &lt;...
What your asking for can't be done using shortcodes . <code> &lt;article&gt; </code> isn't a part of the content, its part of the theme and it 'contains' the content. Thus shortcodes cannot modify it or move those tags around. Shortcodes by definition are part of the content, so anything they add on the end is also a p...
Shortcode append to the the_content()
wordpress
When I post a PHP code snippet into a wordpress post it will convert <code> &lt;?PHP </code> into <code> &lt;!--?PHP </code> To avoid this I must replace <code> &lt;?PHP </code> with <code> &amp;lt;?PHP </code> I am asking if there is a setting or easy method to avoid this? If not I am thinking of maybe writing a PHP f...
Here is my only idea so far <code> function strip_php($content) { return str_ireplace("&lt;?PHP", "&amp;lt;?PHP", $content ); } add_filter('content_save_pre','strip_php'); </code>
<?PHP getting changed into <!--?PHP
wordpress
I created a plugin with a new table ( <code> wp_soundcloud </code> ) and I need to retrieve the data from that new table along with the post data. Here is my query: <code> $querystr = " SELECT $wpdb-&gt;posts.*, FROM $wpdb-&gt;posts LEFT JOIN $wpdb-&gt;soundcloud ON($wpdb-&gt;posts.ID = $wpdb-&gt;soundcloud.idpost) WHE...
Always escape/prepare your data Don't leave it open to injections: <code> global $wpdb; $all_posts = $wpdb-&gt;get_results( $wpdb-&gt;prepare( " SELECT %s.* FROM %s LEFT JOIN %s ON(%s = %s) WHERE %s = 'soundcloud' AND %s = '%s' " ,$wpdb-&gt;posts ,$wpdb-&gt;posts ,"{$wpdb-&gt;prefix}soundcloud" ,$wpdb-&gt;posts.ID ,"{$...
Join new table with SQL query
wordpress
Hi I am trying to create a social network using buddypress.I found a book that has detail instructions on how to create a number of wordpress sites : stackexchange-url ("wordpress blueprints") Just to be clear I have wordpress installed on localhost in e-commerce folder.The first stept that I done was to add this code ...
Newer versions of WordPress have gotten rid of the "Super Admin" menu on the left-hand dashboard menu in favor of a "Network Admin" section. It sounds like you installed multisite just fine, so under the "My Sites" option in the top toolbar, you'll now see a link to the Network Admin section. http://codex.wordpress.org...
Wordpress Super Admin menu not enabled
wordpress
I know how to query the users and create a list of authors and can accomplish this in a page template, much like is described here: stackexchange-url ("Authors Page : A page of authors") my question is then.... is there a way so that i can have www.site.com/author resolve to the page where I am displaying a list of all...
If you use code similar to setup the rewrite rules: <code> function ex_rewrite( $wp_rewrite ) { $feed_rules = array( 'author/?$' =&gt; 'index.php?author_page=author_page' ); $wp_rewrite-&gt;rules = $feed_rules + $wp_rewrite-&gt;rules; return $wp_rewrite; } // refresh/flush permalinks in the dashboard if this is changed...
resolve /author/ to a page or archive (of all authors) template
wordpress
In what order are plugins loaded in WordPress? And within a particular plugin's folder, what order is followed for loading?
First question: In <code> wp-settings.php </code> , WordPress first checks for any must-use plugins (plugins in the optional <code> mu-plugins </code> folder) and loads those. Then, if you're running a multisite installation, it checks for plugins that are network-activated and loads those. Then it checks for all other...
In what order does WordPress load plugin files?
wordpress
I've just set up a new wordpress blog, and as a developer I want to post some source code as well. Now I found the suitable plug-ins I need, and also a sleek theme, or so I thought. The problem is the width, it's just way too small. Even if I pick the option this theme has to only use a single column, it's still not wi...
It will be good if you can pick up a theme that is wide enough for your requirements. Probably a theme based on 1140 grid system will work good for you. That said, if you still want to use your existing theme then you can edit theme's <code> style.css </code> , on line 76 you can delete <code> max-width:1000px </code> ...
Themes with variable width or single columns? I want to display source code
wordpress
I have a Wordpress with the Super Skeleton theme (http://themeforest.net/item/super-skeleton-wp-responsive-minimal-beautiful/647570) installed on my server. Now I want to move it to another server. I have gone through the usual steps of moving a Wordpress and the Wordpress itself works great, but for some reason the se...
The theme is using Option Tree to save the theme options and this is the steps I went through to export the options from the old Wordpress installation and import them into the new one. Go to <code> Users &gt; Your profile </code> and check the checkbox in the bottom saying <code> Show Settings &amp; Docs </code> under...
Moving Wordpress with Super Skeleton theme
wordpress
How can i get the name of a page's parent? I can only get it's id. <code> $page = get_queried_object(); $pageparent = $page-&gt;post_parent; </code>
Once you've got the id of a post or page, use <code> get_the_title($id) </code> to get the page title (which is what I assume you mean by name) Codex Reference
Get page-> parent's name?
wordpress
Hi I am trying to link to some custom templates I have created and I don't seem to know how to do it the right way.For example: I have created a custom contact page and named it contact.php.From the front-page I want to link to it.Now this is what I did but I don't think this is the best way: <code> &lt;a href="&lt;?ph...
You'll want to use the <code> get_permalink </code> function like so: <code> &lt;a href="&lt;?php echo get_permalink(get_page_by_path('contact')); ?&gt;"&gt;Contact&lt;/a&gt; </code> Which will return the correct URL no matter what your permalink settings are.
Linking beetween pages in wordpress
wordpress
There is a problem with WordPress Form Manager plugin that doesn't sanitize the uploaded file filename. So, when a user upload a photo with special characters in the filename, you will not be able to show it up on the front-end, for example. My question is, how can I sanitize that? Ps: I already shot the question to th...
I found a way. Change the lines on wordpress-form-manager plugin direcoty -> types -> file.php (around line 109) From: <code> if($fileNameFormat == "%filename%"){ $newFileName = $pathInfo['filename']; } </code> To: <code> if($fileNameFormat == "%filename%"){ //Sanitize the filename (See note below) $remove_these = arra...
How to sanitize uploaded file filename from a plugin?
wordpress
I have a website with many authors and posts. I need to create a list of all authors and for each one display his latest post (not posts, only one post ). This better explains what I need: <code> &lt;ul&gt; &lt;li&gt; &lt;h2&gt;name of the author&lt;/h2&gt; &lt;a href="his latest post"&gt; Title of his latest post &lt;...
In @Sagive SEO answer get_users_of_blog() is a depricated function. What is below code do get all authors <code> display name </code> and <code> id </code> in <code> $authorsList </code> Loop threw each author id and use <code> WP_Query </code> to get latest post of each author <code> &lt;?php $authors=get_users(); $i=...
Display all authors and their only one latest post
wordpress
I using custom $wp_query for most of my archive pages like, taxonomy,index,category and author page. Everything working fine, except one weird thing - the author template page pagination failed to work. The pagination stop to work on page 2 it direct to the 404 page. Pagination on other archive page, works perfectly. H...
You have a couple of issues here, the main one being that your query sets posts per page to two, but the number of pages available has no relationship to your custom query. If your "Blog pages show at most" under Reading settings is set to 10, and an author only has &lt;= 10 posts, there is no second page. The other is...
Pagination only won't work in author template
wordpress
I want 3 post with one loop iteration, so I'm using <code> the_post() </code> to achieve this: (html removed) <code> &lt;?php while ( have_posts() ) : the_post(); the_title(); the_post(); the_title(); the_post(); the_title(); endwhile; ?&gt; </code> The problem starts, if number of posts is not divisible by 3. For exam...
Ultimately, this question is off-topic , because the solution has nothing to do with WordPress. Outputting posts in a grid pattern is an HTML/CSS issue, and the best-practice solutions don't involve putting every three posts inside a separate containing <code> &lt;div&gt; </code> . Even so, you can do what you want to ...
Multiple posts with one loop iteration
wordpress
I know I can add capabilities to the any role using the role object and add_cap via functions.php <code> &lt;?php // get the the role object $editor = get_role('editor'); // add $cap capability to this role object $editor-&gt;add_cap('edit_theme_options'); ?&gt; </code> The list of capabilities shows that "edit_theme_o...
It's stupid, but you can't. (Not without editing core, anyway.) Right at the top of the nav-menus.php source code is an <code> edit_theme_options </code> check that's not filterable. http://core.trac.wordpress.org/browser/tags/3.4.1/wp-admin/nav-menus.php If you're not concerned about your editors trying anything too s...
How to add only a (sub) capacity to an user role?
wordpress
Lets say I have a function set up like such: <code> add_action( 'init', 'jigoshop_add_to_cart_action' ); function jigoshop_add_to_cart_action($url = false){ //code } </code> To make it pluggable by others plugins, I just need to change this to <code> add_action( 'init', 'jigoshop_add_to_cart_action' ); if (!function_ex...
No, because you're hooking it to an init action, then somebody can replace the function simply by unhooking it themselves. You don't really need to wrap it or make it pluggable.
Very Quick Custom Pluggable Function Question
wordpress
I am creating some sliders type functionality for my wordpress theme and I thought that creating two seperate db tables like 'sliders' and 'slider_images' is a good idea. My problem is that i don't know what is the best way to handle the creation of those tables. If it was a plugin, I would just do it on activation, bu...
Don't use separate database tables in a Theme, especially for creating custom content types. Use WordPress-core Custom Post Types.
Database Tables in Wordpress Theme
wordpress
<code> comments_number() </code> is quite useful: It takes the result of <code> get_comments_number() </code> and prepares the output with some localization magic. Unfortunately, it prints the result out when it is done, it doesn’t offer an option to just return the string. How can I get the string without printing it?...
Easiest way: <code> ob_start(); comments_number(); $data = ob_get_clean(); </code> $data will contain the text.
How to get the result of comments_number() as a string instead of printing it out?
wordpress
I was wondering which is the correct method to do this and which action hook should i use. I have custom login/register pages so if the user try to go to a forbidden page and its not logged in i will redirect him to a login page. Currently on my functions.php i got the following: <code> /* * Restrict non logged users t...
I couldnt find a better method other than: <code> /* * Restrict non logged users to certain pages */ add_action('template_redirect','my_non_logged_redirect'); function my_non_logged_redirect() { if ((is_page('mi-perfil') || is_page('agregar-empresa')) &amp;&amp; !is_user_logged_in() ) { wp_redirect( home_url() ); die()...
Proper method to restrict non logged users into certain pages
wordpress
This is what I am trying to do: Lets say I have a parent plugin, Plugin X, and a child plugin (an extension, whose purpose is to enhance X) Y. There is a function in plugin X that I wish to add code to, from plugin Y. In other words, I am writing plugin Y. Using WordPress, I know there is a way to override Plugin X's l...
This would depend on the way the plugin was structured. If it is just procedural then your pretty much out of luck. If it is written within a class you can extend or create a new instance of it and override methods. As an example in my media tools plugin I use a portion of Regenerate Thumbnails by calling <code> if ( c...
How Can I Add Code To A Preexisting Function Without Editing it
wordpress
I have the settings so only one post (which is by default the most recent) displays with index.php my current working code <code> &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; </code> How could I change to code to display a random post from any category/date? It just needs to be one post if that...
Place the following code in your theme functions.php file. <code> function one_random_post_on_home_page( $query ) { if ( ! ( $query-&gt;is_home() &amp;&amp; $query-&gt;is_main_query() ) ) return; $query-&gt;set( 'orderby ', 'rand' ); $query-&gt;set( 'posts_per_page', 1 ); } add_action( 'pre_get_posts', 'one_random_post...
display random posts on index.php instead of latest
wordpress
I turned on my Debugger and got this error... <code> Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in /home/content/19/9468119/html/wp-includes/functions.php on line 2705 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_...
From your title: <code> register_sidebar_widget() </code> is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. Somewhere in your Theme - in <code> functions.php </code> , or in a function included within <code> functions.php </code> - you're adding custom Widgets. Look for that code, and replace u...
register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead
wordpress
Is it possible to not use the loop for the base URL of a custom post type. So for instance if my custom post type is 'directory'. I don't want http://www.mysite.com/directory/ to land at the loop page, I want to make a custom page template that will serve a customised layout for proceeding into areas of the custom post...
You need the <code> has_archive </code> option set to <code> true </code> when registering your custom post type with the <code> register_post_type </code> function, in order for the archive-{posttype}.php file to work.
Custom Post Type Base URL
wordpress
I'm programming a plugin in Wordpress and want to access some database functions with in my theme with the do_action feature. First I just included $fdb-> get_finaboo_footer(1); on my page for example but he couldnt find the object. I added global $fdb; Then it worked. But I dont want to globalize on every php file the...
I recommend to add a static method to access the plugin instance. Example, taken from stackexchange-url ("this answer"): <code> class My_Plugin { private $var = 'foo'; protected static $instance = NULL; public static function get_instance() { // create an object NULL === self::$instance and self::$instance = new self; ...
add_action in class and use it in theme
wordpress
I'm working on a custom post type. It has meta boxes, and it also adds meta boxes to other post types. It comes with some convenience functions to find posts of its type or the meta data it adds to existing post types. It also has some helper functions to render markup into a template. All this adds up to quite a few '...
I have been working on a theme template to speed up my work progress lately and custom post types where taking a lot of my time. These are a few simple functions that may be able to help you <code> function theme_template_create_post_type( $post_type, $labels = array(), $post_args = array() ) { if ( !$labels || count( ...
Are there established patterns for developing custom post types?
wordpress
I get a white page in the frontend (not in the backend) after inserting the php code for the custom post type. See code: page-custom.php: <code> &lt;div class="infoboxen"&gt; &lt;div class="box"&gt; &lt;?php $loop = new WP_Query( array( 'post_type' =&gt; 'drei_boxen', 'posts_per_page' =&gt; 10 ) ); ?&gt; &lt;?php while...
You forgot about <code> endwhile; </code> at the end of loop. Using template don't forget to <code> get_header() </code> and <code> get_footer() </code> Sample: <code> &lt;?php /* Template Name: Test */ ?&gt; &lt;?php get_header(); ?&gt; &lt;div class="infoboxen"&gt; &lt;div class="box"&gt; &lt;?php $loop = new WP_Quer...
white page after php code insert for custom post type
wordpress
I want to make a php class that gets an option from the wp database (which is an array of options) and be able to call this class with the name of the option and the class to return the options value. Does anyone know how would I go about doing this? EDIT: I have tried the following code <code> class N_Options { functi...
If you have registered your option without setting the fourth parameter <code> $autoload </code> to <code> no </code> your calls to <code> get_option </code> will not trigger any extra database call because all aotoload options are stored in the cache when the site is loaded. To test it add … <code> define( 'WP_DEBUG',...
Get options from database using php class
wordpress
I have set a custom column for date in admin, but the sorting is not working, when I click to sort the dates are jumbled up and not sorted correctly. This is the sorting function Im using <code> function sortable_columns() { return array( // meta column id =&gt; sortby value used in query 'publishdate' =&gt; 'date', //...
This tutorial from WPTuts+ will do the trick ... Quick Tip: Make Your Custom Column Sortable In a recent article by Claudio Simeone, he demonstrated how you could add extra columns to your post, or custom post type, admin screens (or remove existing ones). In this quick tip I build on that by showing you how to make yo...
How to Sort Custom columns in admin
wordpress
How can I link to the posts page that has been set in Settings > Reading? This is for a premium theme so it can't just be the page's permalink.
WordPress Does it like this this. <code> echo get_permalink( get_option( 'page_for_posts' ) ); </code>
How do I link to the posts page?
wordpress
On my homepage, I have several links that should link to different parts of my website. The first link should be redirected to a custom post type that has the slug portfolio. The other links should be redirected to different custom template pages like contact page , about us page, etc. Are there any functions in WordPr...
There are functions in WordPress that deal with adding menu items. Is this the kind of "function" you're looking for? http://www.acousticwebdesign.net/wordpress/how-to-create-wordpress-3-navigation-menus-in-your-theme-or-plugin-code/
WordPress linking
wordpress
Hi I have set a custom post type with some custom fields, one of the custom fields is a date field which is different from the publish date of the post itself, which is by default used by WordPress to sort the posts. I would like posts on this screen to be by default sorted using the custom field. How can I do that, is...
Adding Columns to Admin To answer your first question, I recommend a plugin called Codepress Admin Columns . This is by far one of the easier and non-coding ways to implement columns. But it will set you back 15EUR to purchase the add-on that allows sorting. If you wish to get your hands dirty with code then this post ...
How to change order of posts in admin
wordpress
Hi all I have a loop that shows a post on a single page and puts the first category name in the variable $cat: <code> $cat = $category[0]-&gt;cat_name;?&gt; </code> Now after the post I have a link to show related posts based on this category: <code> $catPosts1 = new WP_Query(array('category_name'=&gt; $cat, 'orderby' ...
You'll have to get the child or parent categories yourself and pass all the IDs as an array via the <code> category__in </code> argument of WP_Query . You can use <code> get_ancestors </code> to get the top parent category, and get all child categories of that parent via the <code> child_of </code> argument of <code> g...
WP_Query not looking at child category
wordpress
I have setup in admin to have 5 comments per post display, which is what I want, and newest at the top. But the problem is when a 6th comment is made it is the only one displayed and you can read the previous comments which will display 5. What I would like it to do is always display 5 comments, when 6th is made the ol...
Ended up solving this with the following code: <code> &lt;ol class="commentlist"&gt; &lt;?php $comments = array_reverse($comments, true); ?&gt; &lt;?php /* Loop through and list the comments. Tell wp_list_comments() * to use twentyten_comment() to format the comments. * If you want to overload this in a child theme the...
Custom setup of wordpress comments that are displayed
wordpress
Is it possible to remove all references to 'edit' or 'add' from a particular post type on its post list display screen in admin? So basically what I need is that for this post type, all roles defined, whatever they are, can only view a list of these posts, and not do anything with them except trash them. So that means ...
For say the 'moomin' post type, when defining the custom post type specify its 'capability_type' as 'moomin'. This will give you the 'capabilities' edit_moomin' etc which you can then remove from individual roles, e.g.: <code> global $wp_roles; // remove capability edit_moomin from role editor $wp_roles-&gt;remove_cap(...
Remove edit or add facility for custom post type
wordpress
i want to get the 5 images of a one post gallery and show this random, example : [gallery id="123" orderby="rand" {numberpost=1 } or offset ? ] [gallery] codex tanks for help me.
Try installing the following plugin: http://wordpress.org/extend/plugins/gallery-extended/ You'll be able to set how many images to show via this code: <code> [gallery link=file start=1 end=5] </code> Hope this helps!
how to show last 5 images from the one post gallery
wordpress
Hi I have created my index.php file as a blog template and on my website I am creating a page using that template.The problem is that by doing it this way pagination is not working anymore.It worked when index.php was my home page.This is my code: <code> $index_query = new WP_Query(array( 'posts_per_page'=&gt;'3', 'pos...
Try add the "page" var to the WP_Query statement <code> $index_query = new WP_Query(array( 'posts_per_page'=&gt;'3', 'paged'=&gt;max(1 , get_query_var('paged')), 'post_type'=&gt;'post' )); </code> Is it the loop that is not paging through the posts, (it just displays the same ones no matter what page you are on? Or is ...
Pagination not working on page template
wordpress
I am using a breadcrumb code that will not place a link on two custom single post pages linking back to two custom post type index pages. The full Breadcrumb code can be seen here: http://pastebin.com/xNwXxWv6 <code> if(get_post_type() == 'Portfolio'){ echo '&lt;a href="' . 'http://www.mysite.com/web-portfolio' . '"&gt...
If you read the codex you will see that <code> is_single </code> accepts post id's / titles / slugs and EDIT If you are using two custom post types then WP will select the right <code> single-POSTNAME.php </code> And in your check you best check the posttype like: <code> if ( get_post_type() == 'postfolio' ) { /*do stu...
Single Post Breadcrumb not linking back to Custom Post Type Index?
wordpress
I use this codes in my functions.php to track post views. <code> /* Functions to track Post Views*/ function getPostViews($postID){ $count_key = 'post_views'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View...
I found a problem :) $my_query = new WP_Query( "meta_key=post_views&amp;orderby= meta_value_num &amp;order=DESC&amp;posts_per_page=5&amp;paged=$my_paged" );
Query is not work
wordpress
I'm using RSS as a tag for some of my blog posts, and I was using them without any problem. <code> myblog.com/tag/rss/ </code> But I've just realised that Google Webmaster Tools gives me some related errors. The issue is this: when trying to retrieve the feed of this tag, from <code> myblog.com/tag/rss/feed/ </code> it...
It's not possible to do yet due to a bug in Wordpress core . A workaround was provided in Wordpress ticket <code> function disable_canonical_redirection_for_tag_feeds() { if ( is_feed() &amp;&amp; is_tag() ) remove_action( 'template_redirect', 'redirect_canonical' ); } add_action( 'wp', 'disable_canonical_redirection_f...
Problem using the word "RSS" as a tag
wordpress
I am trying to activate second plugin automatically while activating first plugin. <code> register_activation_hook(__FILE__, 'example_activation' ); function example_activation() { include_once(ABSPATH .'/wp-admin/includes/plugin.php'); activate_plugin('hello.php'); } </code> Its not working inside register_activation_...
For full explanation of what's happening see this post (this is for deactivating plug-ins, but the problem is the same). A brief explanation: Plug-ins are essentially activated by adding them to the array of active pug-ins stored in the database. When you activate the first plug-in, WordPress retrieves the array of all...
Why activate_plugin is not working in register_activation_hook
wordpress
I want to provide 2 buttons in one form. User click either button can submit the form but do different jobs-- one button is to import checked files, another button is to create fiels. Will this confuse Wordpress?
If you're placing a button in a meta box, it is included within the FORM tags for a post. A simple answer is no, you shouldn't place a submit button in the post form. However, nstead of using a normal <code> input[type=submit] </code> , use the following: <code> &lt;button type='button' name='button-name' id='button-id...
Can I have two submit buttons in one form?
wordpress
I am trying to create a multi-select category list in a theme options page and everything shows up but when i save the options only the last option from the multi-select box that is selected gets saved to the database. Does someone know what I'm doing wrong perhaps? Here's bits and pieces of the code I'm currently usin...
This may be an HTML issue. For a multiple select, the name of needs to end in "[]", to signify an array. So try changing: <code> &lt;select name="&lt;?php echo $themename_option_name.'['.$valueid.']'; ?&gt;" id="&lt;?php echo $themename_option_name.'['.$valueid.']'; ?&gt;" multiple="multiple" style="height:150px; min-w...
Category List in Theme Options Page
wordpress
I've run across the following snippet in themes from time to time: <code> if ( ! defined('ABSPATH')) exit('restricted access'); </code> It's at the beginning of some (all?) PHP files in a theme and it's supposed to prevent direct access of the file by nefarious sources. I see that this isn't included in Twenty Ten or E...
Usually, you don’t need it. But … there is at least one edge case: If a theme file is a template part , and it is using global variables from the calling context (parent file), and register_globals is <code> on </code> , and it is just using these variables without any security check … … an attacker can call this file,...
Worthwhile to restrict direct access of theme files?
wordpress
I want to change a the names of some of the fields in the edit profile page in the backend. For instance, instead of it saying "Twitter", I want it to display "Enter Twitter ID". I am aware that I can do this by editing the core WP files, but to avoid redoing the same process, how can I do this through the function.php...
What you need to look at is hooking into the <code> user_contactmethods </code> filter. Perhaps something along these lines: <code> function test_new_contact(){ $user_contactmethods = array( 'aim' =&gt; __('AIM'), 'yim' =&gt; __('Yahoo IM'), 'jabber' =&gt; __('Jabber / Google Talk'), 'twitter' =&gt; __( 'Enter Twitter ...
Customize field names in backend profile edit page through function.php
wordpress
I just created an intranet site for the company that I work for. The IT department will not allow my site to access the internet for security reasons, but my boss still wants Google Analytics installed. I usually just use Joost De Valk's GA plugin, but I don't think it will work since I don't have internet access. Any ...
Remember that GA runs client side in the browser and if your intranet visitors do not have access to GA servers via the internet then GA is not going to work for you. With that said, Joost De Valk's GA plugin has a way to manually enter the UA code rather than using a connection to Google to pull available UA codes. Th...
How to install Google Analytics onto site without internet access
wordpress
i have created a sidebar in my wordpress site. i want this sidebar to be displayed on each of my pages and subpages in their respective admin editors. i want the sidebar to contain a list of specific posts with checkboxes to select them independantly or together. each checked post must then be displayed on my site wher...
You can use the WordPress Settings API to do what you're looking for. You can follow this - WordPress Settings API Tutorial ( www.ottopress.com ) to setup an options page, and depending upon the options saved in database you can show different content. Example - <code> &lt;?php // get the stored value in variable - foo...
Is it possible to control content on different pages by checkboxing wich content is shown where on a wordpress theme page?
wordpress
What is the different between this (http://pastebin.com/PX0YB0hy) and (http://pastebin.com/VBqiMHVQ) for JQuery Masonry. Why does the first one work and the second one doesn't. In both cases I used wp_enqueue_script to add the script. Thanks!
This executes, when the DOM has been constructed, before all content has been loaded <code> $(document).ready(function(){ ... }); $(function(){...}); // short form </code> This executes, when all content has been loaded <code> $(window).load(function(){ ... }); </code> This executes immediately, when it is first encoun...
Script for initializing JQuery Masonry for Wordpress
wordpress
i know the issue of migrating a local dev site to a live site has been discussed extensively, but i'm wondering how to do this without any downtime. i'm working on a local copy of my live site to integrate a new theme. being as some of the theme admin settings are different (upload logo, widgets, menus, templates, etc)...
Can you install a new wp next to your existing install? I assume you can. Your only argument is changing the domain would take long. If you do a new install in a subfolder. And when finished just edit your <code> .htaccess </code> file accordingly. It should be close to immediately.
migrating local dev site to live site with no downtime
wordpress