question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Because of using slow connection these days, I would like to force WordPress's Admin section to be cached in browser (FF,IE) so that it it takes less time to load admin pages (because in fact, most of items never change.). Is there any way to do that?
your problem is not with the admin pages themself, they are simply not big enough to be hugely impacted by slow connection, but with JS and CSS files. You can set an expiry date for them which will signal to the browser it may cache them until that time. To cache them for a week in your .htaccess file add (idea taken f...
how to force caching of wordpress admin
wordpress
Code is the problem or is a Google Chrome issue? Here is the code: <code> /*-----------------------------------------------------------------------------------*/ /* Create the widget /*-----------------------------------------------------------------------------------*/ add_action('widgets_init', 'bd_post_types_init');...
I find the problem . The issues are caused by Internet Download Manager extension. When is disable, the tabs works. Is there a way to fix this compatibility?
Custom tabs widget don't work in google chrome, is blocked, do not change the tabs. Why?
wordpress
WP 3.5, nginx (latest) and PHP5-FPM (latest). If you visit http://bombacarta.com/?s=coma the page is properly loaded. When you click on the link to go to the next page, you are redirected to the home page. Try it out: http://bombacarta.com/page/2/?s=coma I don't know what's the cause to this... I think it's something r...
Solved changing the location block with this: <code> location / { try_files $uri $uri/ /index.php?$args; } </code>
Second page (and next) of search results redirects me to the home page
wordpress
I would like to able to redirect to <code> get_bloginfo('url'); </code> after reseting password. But I cannot for life of me find any simple answer or function to do this. Does anyone know if this is possible? Thank Josh
Here is a simple solution. Im hooking into <code> login_headerurl </code> . Maybe there is a better hook for this but it works, Put this in your functions.php: <code> function wpse_lost_password_redirect() { // Check if have submitted $confirm = ( isset($_GET['checkemail'] ) ? $_GET['checkemail'] : '' ); if( $confirm )...
wordpress redirect after password reset
wordpress
According to the Codex , wp_enqueue_script supports protocol relative, or protocol agnostic external links: "Remote assets can be specified with a protocol-agnostic URL, i.e. '//otherdomain.com/js/theirscript.js'." But I'm not seeing it: <code> wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?&amp;se...
The code you posted works fine and results in this in the HTML output: <code> &lt;script type='text/javascript' src='//maps.googleapis.com/maps/api/js?sensor=false&amp;#038;ver=3'&gt;&lt;/script&gt; </code> Tested on WordPress 3.5 with this code snippet: <code> add_action('wp_enqueue_scripts', 'test'); function test() ...
How can I enqueue protocol relative external (//ajax.googleapis.com/...) scripts?
wordpress
I'm aware that there is a plugin that will do this, but it is too broad for what I would like to add. Below is my first attempt at expanding the search to query custom fields, but it's returning nothing. I've written code in the past to create queries, but this is my first time trying to modify a pre-existing one and I...
Add this temporarily to your <code> functions.php </code> . It will break things but you can see the <code> WHERE </code> clause. Be sure to remove it because things won't work right if you leave it there. <code> function dump_where($w){ var_dump($w); } add_filter('posts_where','dump_where'); </code> The first thing yo...
I'm trying to expand the scope of the default WP search algorithm. What am I doing wrong?
wordpress
After I added a post by wp_insert_post(); Any callback after I added ? I need permalink of added post. I have idea only search by title and post-type (I use custom post-type in my case), But any better function ?
<code> $post_id = wp_insert_post( $arg ); #returns post ID $permalink = get_permalink( $post_id ); #returns the permalink </code> Codex: http://codex.wordpress.org/Function_Reference/wp_insert_post
wp_insert_post() Callback?
wordpress
I want to add a post title to all of my posts apart from those that are marked as "aside" or "link" post formats. I'm currently using this code to hide the post title for aside posts; <code> &lt;?php if (! has_post_format('aside')) { ?&gt; &lt;?php the_title();?&gt; &lt;?php } ?&gt; </code> How can I target the "link" ...
Edited: Now that I understand your question, try this... Place this above your title to enable the post_class function. <code> &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt; </code> Then add <code> &lt;/div&gt; </code> below your title (or excerpt, or wherever you want this special styling ...
Target all posts that are NOT aside or link post formats
wordpress
I have uploaded a file as my main logo within the theme settings but would like a different logo on the main page. The theme I am using has a custom css option within the theme settings, can I use custom css to only change it on the front page and not the rest of the site? Theme: http://demo.ghostpool.com/?theme=bounce...
It looks like the theme designer has a means for you to use a different logo on the homepage. Looking at your <code> header.php </code> on lines 83-93. If your theme detects that this is the front page, the title is enclosed with an <code> &lt;h1&gt; </code> tag, otherwise it is enclosed in a <code> &lt;div&gt; </code>...
Different logo on homepage
wordpress
When I do this: <code> $transients = $wpdb-&gt;get_col( " SELECT option_name FROM $wpdb-&gt;options WHERE option_name LIKE '_transient_wb_tt_%' " ); </code> It works fine, but when I use prepare like so: <code> $transients = $wpdb-&gt;get_col( $wpdb-&gt;prepare( " SELECT option_name FROM %s WHERE option_name LIKE '_tra...
I agree with @bainternet. You don't need <code> $wpdb-&gt;prepare </code> . There isn't any user supplied content. The answer to the question is that to get a wildcard <code> % </code> to pass through <code> prepare </code> you need to double it in your code. <code> LIKE '_transient_wb_tt_%%' </code> Try that or this i...
prepare() not working
wordpress
I have created wordpress template that uses two loops via WP_Query object. Everything works fine except Search widget . I've been pulling my hairs out for three days now Googling like a madman,but didn't find a solution. For example in my searchbox I type: First cat (that is the name and content of my post inside "cat"...
Somebody shoot me please... Since this is the first theme I developed I didn't know that I needed a search.php for my form to work! Anyway I created search.php and inserted The Loop, after I did that I've copied that file inside my theme and my search form worked like a charm!! Hope this will help somebody else :) My s...
Search widget breaks when using multiple loops?
wordpress
I have a CPT for events. I need to display future events for people to register, while hiding past events. What is the easiest date format for both (1) entering date when creating new event and (2) comparing event dates with current date ?
The date format for entering the date is largely irrelevant. <code> strtotime </code> will convert a lot of different formats to UNIX time . Just make sure your input format makes sense to your users and make sure that your feed <code> strtottime </code> a format that correctly converts to UNIX time . If you are storin...
Date comparison : which date format?
wordpress
I created page "play" url: <code> http://localhost/myweb/play </code> and inside of page "play" I include PHP code to make the new search from outside Wordpress. And all worked, if I search from my page "play" the url will be: <code> http://localhost/myweb/play?m=text+Search&amp;pageno=1 </code> Now, I want my search r...
Only way I knowit to do this it's using this function: /* * Redirects search results from /?s=query to /search/query/, converts %20 to + * @link http://txfx.net/wordpress-plugins/nice-search/ * ======================================= */ function search_redirect() { if (is_search() && strpos($_SERVER['REQUEST_URI'], '/w...
add new permalink structure from dynamic page
wordpress
I use nextgen gallery in a multisite. How can I disable all scripts and styles? These thing are loaded in the code of my site: <code> &lt;link rel='stylesheet' id='NextGEN-css' href='http://mysite.com/wp-content/plugins/nextgen-gallery/css/nggallery.css?ver=1.0.0' type='text/css' media='screen' /&gt; &lt;script type='t...
This takes care of NextGEN's slideshow and CSS, as well as the Shutter script and CSS that it also enqueues by default. <code> add_action('wp_print_scripts', 'wpse_82982_removeScripts'); add_action('wp_print_styles', 'wpse_82982_removeStyles'); function wpse_82982_removeScripts() { wp_dequeue_script('ngg-slideshow'); w...
Disable all scripts and styles from NextGEN Gallery?
wordpress
I have problem about categorizing wordpress TAG, in my case for language. for example: postA : englishtag1,englishtag2,englishtag3, chinesetag1,chinesetag2, postB : englishtag2,englishtag5,englishtag4, chinesetag1,chinesetag3, i want to show tag cloud based on the "language": english tag cloud : englishtag1,englishtag2...
finally found plugin to achieve this using plugins below http://wordpress.org/extend/plugins/tag-groups/ http://wordpress.org/extend/plugins/xili-tidy-tags/ &lt;&lt; complex one hope help someone htat need to groups the tags, catgeory or taxonomy
Categorize wordpress tags
wordpress
I'm building a custom author.php template. I use this to get the author by slug <code> $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); </code> Now my loop uses the author's ID like this <code> &lt;div class="author-products"&gt; &lt;ul&gt; &lt;?php $args = a...
Try <code> 'author' =&gt; $curauth-&gt;ID </code> instead of <code> 'author_id'=&gt; $curauth-&gt;ID </code> since <code> author_id </code> is not a valid parameter.
Quest and filter posts by author ID on author page
wordpress
I work with a university that already has a domain name that ends in <code> .edu </code> (clari.buffalo.edu). I want to use this domain name as we have decided to migrate our web page to WordPress. From the sign up page , it appears that <code> .edu </code> is not supported. Is this true? If not, how can I use a <code>...
I think you're confusing <code> wordpress.org </code> vs <code> wordpress.com </code> . If <code> wordpress.com </code> is what you're looking for, this isn't the place. Per the stackexchange-url ("About page of WPSE"), Don't ask about... WordPress.com support issues Now, if you're referring to using self hosted WordPr...
How to use a .edu domain with WordPress?
wordpress
I'm having a problem with my Wordpress install. All of a sudden some of my posts return 404 errors when I try to go to their permalink. My post names are all numbers and this started happening when my numbered posts went over 1000. So for example, this post works correctly: http://kidlolly.com/post/999/ But this one re...
As I mentioned in my comment, the date rewrite rule is picking up your post permalink and trying to load a year archive instead of your single post. Since it appears you don't use date URLs on your site, you can change the date structure so it no longer clashes. Add this to your theme's <code> functions.php </code> fil...
Some posts returning 404 instead of displaying post
wordpress
I want to hide the div class "navmain2" if the menu is empty. See code below: <code> &lt;!-- Start main navigation --&gt; &lt;div class="navmain2"&gt; &lt;div id="logo"&gt;&lt;/div&gt; &lt;!-- Gets main menu by id --&gt; &lt;span&gt;&lt;/span&gt; &lt;?php wp_nav_menu( array( 'menu' =&gt; 11, 'container' =&gt;false, 'me...
Assign the menu to a string: <code> $menu = wp_nav_menu( array ( 'echo' =&gt; FALSE, 'fallback_cb' =&gt; '__return_false' ) ); if ( ! empty ( $menu ) ) { echo '&lt;div class="navmain2"&gt;' . $menu . '&lt;/div&gt;'; } </code>
Hide main div if wp_nav_menu is empty
wordpress
I'm trying to retrieve all the categories which are related to a specific post, using the <code> wp_get_post_categories() </code> function. The problem is that it is a custom post type, so I tried sending it in the $args array : <code> wp_get_post_categories($id,array('post_type'=&gt;'product')); </code> but that retur...
Are you sure it a <code> category </code> , and not a custom taxonomy ? If it is a category try: <code> var_dump( wp_get_post_categories( $id ) ); </code> or its equivalent since <code> category </code> is a taxonomy: <code> var_dump( wp_get_object_terms( $id, 'category' ) ); </code>
Get categories for a specific post - Custom post type
wordpress
This third party add-on plugin for Gravity Forms allows you to edit existing posts via the front end when you embed a form in your chosen template. All you need to do is append the GET variable/parameter <code> ?gform_post_id=1 </code> to the end of your URL which contains the current form and it will pre-populate your...
The solution to my problem was to ultimately unhook the construct function on init within the plugin and then re-add the plugin construct function on the <code> wp </code> hook. <code> global $gform_update_post; remove_action( 'init', array($gform_update_post, 'init'), 100 ); add_action( 'wp', array($gform_update_post,...
Preserving $_GET parameter while using custom Rewrite Rule
wordpress
I've been developing a plugin where I wanted to create a table, styled and working just like Wordpress's native Post/Page tables. Following the guide below, I was able to create the table and load my database. The only thing I cannot figure out to do is how to make one of the row contents "clickable". http://wpengineer...
The <code> WP_List_Table </code> class ultimately uses the <code> single_row_columns </code> method to output each table cell. If we look at that method, we'll see this part: <code> ... elseif ( method_exists( $this, 'column_' . $column_name ) ) { echo "&lt;td $attributes&gt;"; echo call_user_func( array( &amp;$this, '...
Create a clickable name in WP_List_Table for Plugin Admin
wordpress
I'm creating a plugin that has some external Javascript and some AJAX calls ... but I don't know the best way to make reference to the <code> admin-ajax.php </code> file since the path requires some input from PHP (paths and such). Should I declare a global javascript variable? What is the best way to accomplish this?
What you need to do is register and/or enqueue your script and then use <code> wp_localize_script </code> to include a Javascript variable on your page. The Codex page has this example : <code> wp_enqueue_script( 'some_handle' ); $translation_array = array( 'some_string' =&gt; __( 'Some string to translate' ), 'a_value...
How to include admin-ajax when loading external javascript
wordpress
I'm using WP 3.5 and Polylang 0.9.8 plugin to make translations to different languages. All is good, and the plugin works fine, but now I'm facing a problem -- I need to translate custom strings , for example, strings inside widgets. What can you recommend me to solve this problem? ADDED: For example (I'm taling about ...
Use this pll_register_string() on functions.php Use it like this: <code> pll_register_string Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes). Usage: pll_register_string($name, $string, $multiline); ‘$name’ =&...
Custom strings for translation using Polylang plugin
wordpress
In the past Media Library window could be called like this: <code> tb_show("Upload image", "media-upload.php?type=image&amp;TB_iframe=1&amp;width=640&amp;height=520"); </code> This still works in WP3.5. But I'm wondering how to open a new media manager? It's no longer handled by Thickbox - <code> tb_show() </code> . Th...
From the article How to use WordPress 3.5 Media Uploader in Theme Options (by codestag.com) , as seen in Using the WordPress 3.5 Media Uploader within plugins (by mikejolley.com) . Mike Jolley's article has quite some nice tricks. Important note : if the page where the uploader is going to be used doesn't already have ...
How to call WP3.5 Media Library manager?
wordpress
I have a site option where users can enter domains to "whitelist" registrations from. What I'd like to do is hook into the invite/create user flow to verify the new user's domain from their email address matches one of the domains in the site options. Does anyone know if this is possible, or how to go about doing that?...
It is possible to hook into <code> wpmu_validate_user_signup </code> , which returns the <code> $result </code> of the sign-up process. Add another check for the email domain whitelist and add an error if not allowed. <code> add_filter( 'wpmu_validate_user_signup', 'whitelist_registration_wpse_82859' ); function whitel...
Can I hook into the invite user process to verify their email address is from a certain domain?
wordpress
I have a made a custom post type called "Member Resources" the posts under this CPT have a few taxonomies such as categories and tags. Tags = "Diversity" Categories = "Guidance" When I go to the following urls: www.domain.com/tags/diversity www.domain.com/tags/guidance No posts appear. Though I have set public => true ...
You were close with the code you posted in your comment. The issue is that you only tested for <code> is_main_query </code> , which will limit every query on your site to that single post type. <code> function wpa82763_custom_type_in_categories( $query ) { if ( $query-&gt;is_main_query() &amp;&amp; ( $query-&gt;is_cate...
Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
wordpress
I thought this would be a simple task, but I cannot find anything on google. I would simply like to echo the meun_order value in my loop. I tried this but it's not in the post_meta table, its in the post's table. <code> &lt;?php echo get_post_meta($post-&gt;ID, 'menu_order', true); ?&gt; </code> Can anyone help please?...
You can't use <code> get_post_meta </code> since the <code> menu_order </code> is stored in the <code> posts </code> table, like you said. But you can set up an easy database query to get the value. <code> $menu_o = $wpdb-&gt;get_var( "SELECT menu_order FROM $wpdb-&gt;posts WHERE ID=" . $post-&gt;ID ); echo $menu_o; </...
echo menu_order value in my theme
wordpress
I created a thread ( How to make www. and no www. Go to same site, for all sites? ) in the support forums for the WordPress plugin: WordPress MU Domain Mapping . Everything is fine and dandy. I have a base domain, along with several other domains. I have added all of the domains successfully. However, I get <code> www....
Answered from this thread . Summary: The .htaccess redirect for www/non-www... <code> # www redirect RewriteCond %{HTTP_HOST} ^subdomain.com RewriteRule ^(.*)$ http://www.subdomain.com/$1 [R=301,L] </code> Put it ABOVE your WordPress rules on domain.com. Should work. Example: <code> RewriteEngine On # DOMAIN #1 - Redir...
How to Force WWW. in Domain With WordPress MU Domain Mapping Plugin?
wordpress
Preface I've installed gravity forms, created a form and users are submitting data to my site. What I want to do is show the data users are submitting to my site on one of my pages. I know there's the Gravity Forms Directory plugin. But this gives only a fixed data presentation. Question Is there anything in gravity fo...
You can look at the docs, but you'll probably end up reading the real documentation: the source code. If you do, you'll find that: <code> GFFormsModel::get_leads($form_id) </code> returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an "Entry object" <...
How do I show data from gravity forms in my template?
wordpress
In my theme, I used this: <code> &lt;div id="brickwall" data-brickinvert="&lt;?php echo brickAlign(); ?&gt;"&gt; </code> I put the code into functions.php: <code> function brickAlign() { $a = "true"; return $a; } </code> Now in the child theme, I would like to change $a to false. Then in child theme my html would look ...
You can make your function filterable: <code> function brickAlign() { $a = "true"; return apply_filters( 'brick_align', $a ); } </code> Then, in your child Theme, add a filter callback: <code> function child_theme_filter_brick_align( $a ) { return 'false'; } add_filter( 'brick_align', 'child_theme_filter_brick_align' )...
Child Theme Variables
wordpress
I use WordPress Multisite. I have multiple sites with plugins installed. I can successfully get a list of the plugin paths with the option value <code> active_plugins </code> from each site. I can not get additional data from <code> get_plugin data </code> . I use this code: <code> $plugins = get_blog_option($blog_id, ...
The problem is the value inside the var <code> $plugin </code> . The function <code> get_plugin_data </code> will use the completed path, like <code> /var/www/wp/wp-content/plugins/akismet/akismet.php </code> . Add the path before your plugin-folder and it works. I think you can use the constant <code> WP_PLUGIN_DIR </...
WordPress Multisite - get_plugin_data()
wordpress
I want to try and remove automatic p tag and br tag addition for my custom post type. It looks like <code> remove_filter( 'the_content', 'wpautop' ); </code> will do this, but how would I make the change only for my chosen post type I've tried writing a function for this, but it doesnt seem to work: <code> function rem...
<code> remove_filter('the_content','wpautop'); //decide when you want to apply the auto paragraph add_filter('the_content','my_custom_formatting'); function my_custom_formatting($content){ if(get_post_type()=='my_custom_post') //if it does not work, you may want to pass the current post object to get_post_type return $...
remove_filter( 'the_content', 'wpautop' ); only for certain post types
wordpress
I need a random redirect button just like 9gag.com I know that i need a add a rewrite rule but i dont know how to do this I tried to use plugins and other codes, but none worked.
you can use this code <code> add_action('init','random_add_rewrite'); function random_add_rewrite() { global $wp; $wp-&gt;add_query_var('random'); add_rewrite_rule('random/?$', 'index.php?random=1', 'top'); } add_action('template_redirect','random_template'); function random_template() { if (get_query_var('random') == ...
How can i add a random redirect button in wordpress?
wordpress
I'm trying to figure out how to get the results from a select box option and apply them to my theme. When I use a text input or color picker it works fine. But when I use a select box, nothing is changing. Here's the option: <code> $options['color_scheme'] = array( 'name' =&gt; __('Color Scheme', 'text-domain'), 'desc'...
I use the same options framework plugin and this is how I specify a select menu using this framework; <code> $test_array = array( 'one' =&gt; __('One', 'options_framework_theme'), 'two' =&gt; __('Two', 'options_framework_theme'), 'three' =&gt; __('Three', 'options_framework_theme'), 'four' =&gt; __('Four', 'options_fra...
Outputting results from select box option in options panel
wordpress
This question stackexchange-url ("here") is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a response. I am trying to implement the colour picker wheel as seen in the Wordpress Theme Customizat...
This drove me mad for a while, but I got it to work by adding them with the full arguments that are used in the admin script loader rather than just referencing the handle. When I print the <code> $wp_scripts </code> global on the front end, <code> iris </code> and <code> wp-color-picker </code> are nowhere to be found...
How do I implement the Wordpress Iris picker into my plugin on the front-end?
wordpress
I've created a plugin with a custom post type that uses the standard editor. Also on the page, I've got a button that causes a jQuery dialog to pop up that also contains the tinyMCE editor created with <code> wp_editor </code> . I would like to modify the list of buttons on the toolbar, but only for the SECOND editor (...
Figured it out. After the first editor has loaded on a page, even if you modify the <code> tinymce </code> settings in the array passed to <code> wp_editor() </code> , those settings are NOT passed along to the <code> tinymce </code> instance that is created when the page is first loaded. Instead you have to use javasc...
How to remove buttons from tinyMCE in wp_editor added via AJAX
wordpress
I have this custom field for a post: <code> key: price value: 2000 </code> I've added this to my loop: <code> &lt;div class="buyitnow"&gt;&lt;?php $price = get_post_meta($post-&gt;ID, 'price', true); if ( $price ) { ?&gt; Price: $&lt;?php echo number_format($price ,",",",",","); ?&gt; &lt;?php } else {} ?&gt;&lt;/div&g...
You have <code> number_format </code> wrong. The second parameter should be a number and you have a string-- a comma. What you want is something like <code> echo number_format($price,2,",",","); </code>
Custom Fields Not Showing
wordpress
This is my case.I created a multi-site installation where users can register and be provided with a subdomain. As of this time, the administrator has not yet enable the creation of sub-domains in the apache configuration, so I manually added the newly created subdomains (from my testing) to my hosts file. After registr...
The problem is in the server configuration. After the administrator fix the subdomain issue. Everything is working fine.
Cannot login to admin panel in multisite install if subdomain is added to hosts file
wordpress
This is a code that I'm adapting from https://gist.github.com/2057532 . The problem is that I'm not being able to save the content from the new fields that I created. I had checked the other questions here, but none helped me. Any idea where is the problem? <code> add_action('admin_init', 'slider_metabox_caption', 1); ...
Using the following code allows you to retrieve the array. <code> foreach ($repeatable_fields as $v) { } </code> Than you can access individual values with something like this: <code> &lt;?php echo $v['text']; ?&gt; </code>
Saving metabox repeatable fields
wordpress
i want to make a single page site which has subpages with following structure about us team -member1 -member2 contact and i want the output to be like <code> &lt;div class="about-us"&gt; team content &lt;/div&gt; &lt;div class="team"&gt; team content &lt;div class="subpages"&gt; &lt;div class="member1"&gt; member1 cont...
To me it's very simple, but a bit static. You can make a new <code> front-page.php </code> with the structure you mentioned. Then first make some pages (i.e.: About us, Members 1, Contact etc.) in your <code> wp-admin </code> . And use the get_page() function to call different page [using their individual ID] into diff...
single page site with subpages
wordpress
This is my entire code. It doesn't save the data I enter on the plugin settings page. I don't have a clue on why this happens! Can somebody please help me? <code> &lt;?php // add the admin options page add_action('admin_menu', 'plugin_admin_add_page'); function plugin_admin_add_page() { add_options_page( 'Revenue Share...
The problem is your validate function <code> RSP_options_validate() </code> . This function always a empty string. Check your conditional statement with <code> preg_match </code> . If you test your source without this functions, it works. <code> register_setting( 'RSP_options_group', 'RSP_options', 'RSP_options_validat...
My first plugin doesn't save the data in options
wordpress
I'm using the the filter below to filter related posts by author, I added an author ID to test but they are not filtering by author <code> add_filter( 'woocommerce_product_related_posts', 'woo_custom_attribute_filter' ); function woo_custom_attribute_filter( $q ) { array( 'orderby' =&gt; 'rand', 'posts_per_page' =&gt; ...
<code> $q </code> should contain the array: <code> add_filter( 'woocommerce_product_related_posts', 'woo_custom_attribute_filter', 10, 1 ); function woo_custom_attribute_filter( $q ) { $q = array( /* args here */ ); return $q; } </code>
Adding a filter to related posts not working
wordpress
I am experimenting with PHP namespacing within Worpdress plugins. The plugin includes a loader file which sets up the spl_autoload functionality and then instantiates a different controller depending on whether the current page request 'is_admin()' or not. [WP_PLUGIN_DIR]/lhes_experiment/loader.php <code> use lhes\syst...
Your <code> set_include_path </code> is wrong. Instead use: <code> set_include_path(plugin_dir_path(__FILE__)); </code> Tested it with your code and it works. For reference: http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
Namespace spl_autoload problem in Wordpress admin
wordpress
Im running a rather large wpmu setup bloggersdelight.dk - from time to time, we need to reset the object cache when doing changes on the site. When we do this, things mess up. Option values from sites gets mixed together and homeurls for blogs redirects to wrong blogs etc. This is the current object-cache.php im workin...
We upgraded to wordpress 3.5.1 and the latest version of object-cache.php this has now solved the problems.
issues with object cache (memcached as backend) and wpmu when flush_all is run
wordpress
Now the order is: apples, oranges, pears . But I want to be in a random order, for ex: oranges, apples, pears . Or to write them in a order that I want. Is this possible? Taxonomy is like that: <code> 'fruits' =&gt; array( 'post-types' =&gt; array('products'), 'name' =&gt; 'Fruits', 'slug' =&gt; 'fruits', 'type' =&gt; ...
[SOLVED] This do the Job: <code> function set_the_terms_in_order ( $terms, $id, $taxonomy ) { $terms = wp_cache_get( $id, "{$taxonomy}_relationships_sorted" ); if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy, array( 'orderby' =&gt; 'term_order' ) ); wp_cache_add($id, $terms, $taxonomy . '_relatio...
How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
wordpress
Trying to move a Wordpress website from Wordpress.com to a self-hosted version. http://onvegetables.com/ The site automatically had infinite scroll on Wordpress.com and I'm trying to implement that on the self-hosted version. Is that feature part of the JetPack plugin? If not does WordPress offer a way to simulate that...
Jetpack does provide the infinite scroll, but unlike other functionality it may require you to modify your theme to support it. Here's a link to the documentation .
Infinite Scroll on Self-hosted Wordpress
wordpress
I created a menu in wordpress in the Menus section of the backend is there any way to display the menu links with commas so it displays as <code> Link1, Link2, Link3, Link4 </code> ?
Use a very simple custom walker … <code> class WPSE_82726_Comma_Walker extends Walker { public function walk( $elements, $max_depth ) { $list = array (); foreach ( $elements as $item ) $list[] = "&lt;a href='$item-&gt;url'&gt;$item-&gt;title&lt;/a&gt;"; return join( ', ', $list ); } } </code> … and call your menu like ...
Add Commas Between Menu Items?
wordpress
An example option i am using: <code> // Layout $wp_customize-&gt;add_setting( $themeslug.'_settings[layout]', array( 'default' =&gt; 'content-sidebar', 'type' =&gt; 'option', 'transport' =&gt; 'postMessage' ) ); $wp_customize-&gt;add_control( $themeslug.'_settings[layout]', array( 'label' =&gt; __( 'Layout', 'anatema' ...
With @Otto's tips, i found the problem. I was calling theme settings in functions.php and was calling settings as global variable in theme files. This was working properly except temporary changes was disappearing in theme customizer's live edit when you change page with clicking links. After this experience, what i am...
Theme Customizer changes are dissappearing when change page
wordpress
I have the following code in functions.php to give me post format support and a custom post type 'photos'. But I would like the post formats to only apply to the 'photos' post type and not to the built-in 'posts' post type. <code> add_theme_support( 'post-formats', array( 'image', 'chat', 'video', 'gallery' ) ); //cust...
Try <code> remove_post_type_support </code> : <code> remove_post_type_support( 'post', 'post-formats' ); </code>
Apply post formats to a specific post type only?
wordpress
My plugin displays its output into a thickbox 'window', the contents of which are generated in load-edit.php. This is a completely bare page, but I want to use some of the admin css styles so that it integrates nicely with the rest of the UI. I can't do a regular admin_enqueue_scripts because nothing from wordpress is ...
Directly answering your question, you should be able use the function admin_url() to get the base URL for the admin folder, and <code> ABSPATH . 'wp-admin' </code> to get the local file path to that folder. Certainly, the WordPress code itself doesn't expect the admin folder to be named anything different. However, you...
check if .min.css stylesheet exists
wordpress
I've been using PDO plugin for wordpress and SQLite database. It does not work as expected so I want to use MySQL database, but without PDO for Wordpress since I cannot trust that plugin anymore, It has not been updated for more than 2 years. So, this is what i did: Exported SQLite database to sql file Made necessary c...
I found out what is wrong. The tutorial says to remove all double quotes " and replace them with spaces or backticks `, but some values in the mentioned tables have double quotes around them. This one for example: <code> INSERT INTO "wp_usermeta" VALUES(14,1,'wp_capabilities','a:1:{s:13:"administrator";s:1:"1";}'); </c...
Migrating from PDO using SQLite to clean new install using MySQL
wordpress
I would like to monitor the number of times a user clicks the hyperlink assigned with a class name link_counter. I'm using jQuery and PHP to do this, for example: <code> $('.link_counter').click(function() { &lt;?php //Retrieve the current count from dB @countdata = $wpdb-&gt;get_var($wpdb-&gt;prepare( "SELECT counter ...
I agree the only way that I can do this with AJAX. I have modified my scripts to include AJAX and it is now working. Thanks.
Custom counter when link is clicked in Wordpress
wordpress
Can't seem to find out what I'm doing wrong. <code> $args = array( 'post_type' =&gt; 'wr_event', // my custom post type 'posts_per_page' =&gt; -1, // show all posts 'meta_query' =&gt; array( array( 'key' =&gt; 'event_announced', // a custom field either "on" or "off" 'value' =&gt; 'on', 'compare' =&gt; 'NOT IN' ) ) ); ...
Your current query will select posts that have a value in the key <code> event_announced </code> which does not equal <code> on </code> . What I think you want is <code> NOT EXISTS </code> , and you can omit <code> value </code> , since you are querying for posts that don't have the key, hence, it will have no value. N...
WP_Query arguments: Loop through custom post type - get all entries except excluded meta_key?
wordpress
I had initially asked a question based on my code (which has since been removed), I need some help/guidance in creating a plugin. Scenario: I have created a custom post type (CPT), now I need to insert values into the CPT from a database table external to the wp environment. This routine needs to run once every hour, n...
Use wp_cron to run a job every hour. http://codex.wordpress.org/Function_Reference/wp_cron Use $wpdb-> get_results to fetch data from your external table. Example: <code> $q = "SELECT * FROM my_table"; $results = $wpdb-&gt;get_results($q, OBJECT); foreach ( $results as $result) { } </code> Insert new CPT-posts using wp...
Inserting into WP DB
wordpress
I'm not sure the appropriate terminology but I have a wordpress "loop" for a custom post type that has roughly 300 results that all get displayed on a single page (no paging). The causes an enormous load on the DB server because for every "post" in the "loop" there are like N database calls (the_title, has_post_thumbna...
You can use the Transients API to cache the entire HTML output so the queries are not done every time the page is loaded: <code> $transient = 'my-300-posts'; $timeout = 3600; // 1 hour if ( false === $out = get_transient( $transient ) ) { $args = array( YOUR ARGS GO HERE ); $posts = get_posts( $args ); if ( $posts ) { ...
Wordpress "Loop" with large set of results
wordpress
Is there a way to disable the sticky option on posts in specific categories?
I ended up going with another approach. I check to see what the current user's role is, then if the role is 'author', enqueued a CSS file to hide the sticky option's checkbox. In the theme's functions.php file: <code> function hide_sticky_option($hook) { global $current_user; if('post.php'== $hook || 'post-new.php'==$h...
Disable sticky option for specific categories
wordpress
I know its quite common now, But I cant find out where I am doing wrong. I have screenshot placed at the right place (both trunk and tag/1.0 ) and used the same tag i.e 1.0 in readmen.txt but still they are not showing up on plugin's screenshots tab. Read me file http://plugins.svn.wordpress.org/nextgen-3d-flux-slider-...
I think there's a problem with your .png's. Are they truly .png files, or possibly .jpg/.gif just renamed to .png? Try saving as a .gif or .jpg and re-upload. Sidenote: unless you need your users to have the screenshots in the plugin .zip, you can upload them to the SVN assets directory instead, and it won't be include...
Screenshot are not showing up on plugin page
wordpress
I got this code to show video loops on my blog. It's working nicely. Function.php <code> function catch_video() { global $post, $posts; $first_vid = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/&lt;iframe.+src=['"]([^'"]+)['"].*&gt;/i', $post-&gt;post_content, $matches); $first_vid = $matches [1] [0]; ech...
At first blush, it appears that you are missing a colon from your else statement. Without more info, though, I cannot tell you anything else. <code> &lt;?php if( has_post_thumbnail() ) : ?&gt; &lt;div class="image-wrapper-hover"&gt; &lt;?php the_post_thumbnail( 'large' ); ?&gt; &lt;/div&gt; &lt;?php else : ?&gt; &lt;?p...
Hover images and Videos
wordpress
Is it possible to create an "Alert" button that can be turned on and off thru wp-admin. Of course the "Alert" button im asking for is to be published at the main page, but can only be turned on when its needed. Im using wordpress with jqueryMobile for your information. EDIT: Its pretty hard to explain this. But i found...
Using the very example from the Codex in the Settings API section. Put it in the theme's <code> functions.php </code> : <code> add_action('admin_init', 'eg_settings_api_init'); function eg_settings_api_init() { add_settings_section( 'eg_setting_section', 'Example settings section in reading', 'eg_setting_section_callba...
Notifications Bar on home page only
wordpress
<code> function build_total_search_method( $atts ) { $shorcode_php_function = include( dirname(__FILE__) . "/includes/total_search.php" ); return $shorcode_php_function; } add_shortcode( 'total_search', 'build_total_search_method' ); </code> I've created a shortcode that returns an included PHP file instead of a string...
You are returning the result of calling <code> include </code> . You want to grab the output of the included file and return than instead. Use output buffering to do that. <code> function build_total_search_method( $atts ) { ob_start(); include( dirname(__FILE__) . "/includes/total_search.php" ); $shorcode_php_function...
Shortcode return is printing a 1 afterward
wordpress
Basically I have so many images associated with custom post type that I need to be able to safely delete all related media on removal from trash. Is there a safe way of doing this?
Is your post to image association custom? If not attachments should be automatically deleted by Wordpess. If the connection is custom, Wordpress provides a delete_post action that fires before and after a post is deleted, it will pass the ID of the post so you can use that to delete all custom content associated with i...
Delete all associated media when custom post type removed
wordpress
I found out I was editing themes wrong, and that I should be using child themes, so I duplicated the theme I was using, and told it to inherit off of its parent. That's about the only thing I did, I was planning on going through and finding the code I didn't touch and removing those files, but I didn't get that far. Af...
You have a PHP error in your child theme which is causing that. If you don't see an error in the apache log, it might be that you PHP errors are stored at some other location, or just not being reported at all. Check your PHP error settings in your php.ini file. Anyway, most likely your problem is caused by the code in...
wordpress every page returning 500 error
wordpress
I've created a custom taxonomy called imagetags using the following code: <code> // Register Custom Taxonomy function custom_imagetags_taxonomy() { $labels = array( 'name' =&gt; _x( 'Image Tags', 'Taxonomy General Name', 'text_domain' ), 'singular_name' =&gt; _x( 'Image Tag', 'Taxonomy Singular Name', 'text_domain' ), ...
The issue is with the <code> post_status </code> argument of the default query generated for your taxonomy terms. If you change the status via the <code> pre_get_posts </code> action to <code> inherit </code> or <code> any </code> , you can get attachments to show up. however - is this the correct way to do this- I hon...
Correct Way To Show Custom Taxonomy for Image Attachments on Template File
wordpress
I tried doing something like this: <code> $user = $wpdb-&gt;get_row(' SELECT * FROM ' . $wpdb-&gt;users . ' WHERE user_pass = "' . wp_hash_password('password') . '"' ); </code> But the <code> wp_hash_password </code> function generates a different string from the one in the database, is it possible? What I'd like to do...
Here's what I ended up doing in case someone else need a similar functionality: <code> // Simple text password $client_password = $_POST['client_pwd']; $users = get_users(); // Iterate over all users and see if the password matches foreach ($users as $user) { // If it matches log the user in if (wp_check_password($clie...
Is it possible to get a user with just the password field?
wordpress
I did some reasearch but couldn't find a way to do it. Just to be clear I don't want to show a widget list of random posts on the sidebar. I want the ability for reader to click on a link that says "Random Post" and it will take them to a random post from my archive. How would I do it? I am php noob, so working code sn...
Looks like you're after Random Post Link . For completeness here's some code (the plug-in is a little more involved as it stores as a cookie previous random posts, so they don't twice). (The following is based on the above plug-in by Scribu) <code> //Create random url - use this where you want the link to be displayed ...
Looking for a way to take readers to random post when clicking a link
wordpress
I've a custom/static "homepage.php" in my templates directory at my WordPress. Now I need to show differents "page excerpts" in my homepage, but I don't know what should be do it. At this moment I've in my "functions.php" de following function: <code> function excerpt_page() { add_post_type_support( 'page', 'excerpt' )...
Thank you very much! Finally, I've succeeded with the following code :D <code> &lt;?php $pages = get_pages('include=10,20,30,40,50,60'); foreach ($pages as $page) { $featured_content = '&lt;div class="four columns"&gt;'. '&lt;h4&gt;&lt;a href="'. get_page_link($page-&gt;ID) .'" title="'. $page-&gt;post_title .'"&gt;'. ...
How to add an excerpt and read more link to a page?
wordpress
I've found some themes for prettify.js and I want to use one of them on my blog. As the Theme Gallery says, I can just download one of the themes, rename the css file to 'prettify.css' and overwrite the original one, to apply a new theme. However, since I am using WP-Markdown, the code blocks are formatted by the embed...
So the css used by the plug-in is actually called <code> demo.css </code> - see file . ( I know, it started as that I've never got round to calling it something more appropriate). The plug-in requires more css that just prettify, however: for example to style the preview box, the toolbar etc. So just replacing the cont...
How to theme code blocks formatted by the prettify.js embedded with WP-Markdown?
wordpress
We have many WordPress sites on different hosts with different domain names. Is there any solution for accessing all posts and settings with a central management tool? It's been very hard for us to open 10 sites in 10 tabs and set one desired configuration in all of them. I know that WordPress has a version for Multisi...
For remote management of many installations of WordPress, I know of two options, one paid, one free. ManageWP ManageWP is a WordPress management console that gives users full power and complete control in managing virtually any number of WordPress sites in the easiest way possible. InfiniteWP Manage multiple WordPress ...
Is there any central control/access panel for several WordPress sites?
wordpress
I've read this post here but am unsure where to start. https://www.varnish-cache.org/trac/wiki/ESIfeatures Edit for clarification: I do want to use Full page caching but once we cache say the article page, it can stay in the cache for a day or so, or if something pushes it out. But I'd Want the sidebar to refresh at a ...
You can do something like the following: If you have a sidebar called "Sidebar" <code> &lt;?php if ( !dynamic_sidebar("Sidebar") ) : endif; ?&gt; </code> You wrap it in ESI tags, one for if ESI is not enabled and one if it is: <code> &lt;esi:remove&gt; &lt;?php if ( !function_exists('dynamic_sidebar') || !dynamic_sideb...
How can I use Varnish Edge Side includes for a sidebar?
wordpress
I have a menu for a website I am designing and there are parent and child elements...I was wondering if there was someway I could add an arrow to my navigation if the parent has a child element? My navigation code looks like: <code> &lt;div id="nav"&gt; &lt;ul&gt; &lt;?php wp_list_pages("title_li="); ?&gt; &lt;/ul&gt; ...
To add arrow for parent elements: jQuery + CSS Solution: JQUERY: <code> jQuery(function($){ $(document).ready(function(){ $('ul.sub-menu').parent().addClass('drop-down'); // Add Sub-Menu Class to insert personalized style $('li.drop-down &gt; a:first-child').wrapInner('&lt;span class="menu-bullet" /&gt;'); // Add .menu...
Menu Arrow for Child Element
wordpress
I'm having trouble understanding when you need to use <code> wp_register_script() </code> . Currently, I just use something like: <code> add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); function enqueue() { $handle = 'some-handle'; $js = 'http://example.com/my.js'; wp_register_script( $handle, $js ); w...
The Codex page literally says: A safe way of registering javascripts in WordPress for later use with <code> wp_enqueue_script() </code> . This means, if you want to register your scripts, but not directly load them in your pages, you can register the files once, and then load them when you need them. For example: You h...
When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?
wordpress
I need to format a custom field in admin area (post edit) as a currency, eq: 12.000,00 , with user typing only the numbers, the , and . automatic. Ive searched arround, with no sucess.. Anyone? thank The code i am trying to use to enqueue script in admin is <code> function enqueue_admin() { wp_enqueue_script( 'jquery' ...
if you want to process the field after submitting, php's number_format function is what you need: <code> $price = number_format( $number, 2, '.', ',' ); </code> but if you want to change how the number is displayed as it's typed in, try jQuery autoNumeric
Currency (price) formating on custom fields
wordpress
I'm trying to put a video as featured in my theme, i mean, to be shown by the tag "the_post_thumbnail ('')", without using any plugin. Is this possible? Thank you!
No, it is not possible as-written in core. <code> the_post_thumbnail() </code> uses the ID of the attachment post-type that has been selected as the featured image for the post, then outputs the image associated with that attachment post-type. You would have to filter <code> the_post_thumbnail() </code> in some manner,...
Insert a Featured Video
wordpress
I've added several meta boxes to post and the function that suppose to save those boxes. When i save menus ( appearance -> menu). it throws a warning for each added menu or sub menu <code> Notice: Undefined index: image_price_variation in /home1/xxx/public_html/xx/wp-content/plugins/xxx-shopping-cart/xxx_metabox_functi...
Check in your function to save the post meta data for the post type or better for $current_screen. The var is a global and return a object with different identifier to check, in which admin page init the function. Check in your function and return if is not the right $current_screen-> id or post_type. Small hint: use t...
added a meta box to post however when saving menu while debug on throws a warning
wordpress
In my Wordpress theme that I've currently been building I do not take advantage of the Wordpress Theme Customization API. As much as I would like too, I've invested far too much time into my own personal theme options framework for changing things. This leads me to my question. How do I remove the blue, "Customize Your...
There are no hooks to that part of the Dashboard. It has to be done with CSS (or jQuery if you want to convert it in another thing). <code> add_action( 'admin_head-index.php', 'hide_customize_button_wpse_82424' ); function hide_customize_button_wpse_82424(){ ?&gt; &lt;style type="text/css"&gt;div.welcome-panel-column:f...
How to remove the Theme Customization Button from the dashboard and themes options page?
wordpress
I am trying to auto-populate an image on a theme page using the native Wordpress media uploader, but I want the image to populate before the option is saved. With the code below, the url to the image is populating correctly into the <code> input </code> field automatically, but I cannot figure out how to get the image ...
In the same call where the image URL is being sent to the editor, you fill up another div with an image source. Like: <code> window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#upload_image').val(imgurl); imgsrc = '&lt;img id="upload_image" name="upload_image" src="'+imgurl+'"&gt;...
Auto-Populate Image After Media Upload
wordpress
I’d like to stop WP from wrapping <code> &lt;p&gt; </code> tags around <code> &lt;div&gt; </code> tags in the TineMCE editor … Here’s what I’ve got: <code> function filter_ptags_on_images($content) { return preg_replace('/&lt;p&gt;([^&gt;]*)&lt;\/p&gt;/i', '$1', $content); } add_filter('the_content', 'filter_ptags_on_i...
Greedy and Ungreedy modifier : <code> preg_replace( '/&lt;p&gt;(.+)&lt;\/p&gt;/Uuis', '$1', $content ); </code> Tested with this script: <code> &lt;?php $c = array(); $c[] = '&lt;p&gt;text&lt;/p&gt;'; $c[] = '&lt;p&gt;&lt;div&gt;text&lt;/div&gt;&lt;/p&gt;'; $c[] = '&lt;p&gt;&lt;div&gt;&lt;div&gt;text&lt;/div&gt;&lt;/di...
Removing tags around tags
wordpress
I just found out that there are no javascript and css links in my header.php. <code> &lt;?php /** * The Header for our theme. * * Displays all of the &lt;head&gt; section and everything up till &lt;div id="main"&gt; * * @package web2feel * @since web2feel 1.0 */ ?&gt;&lt;!DOCTYPE html&gt; &lt;html &lt;?php language_att...
They are probably loaded in your functions.php file in your theme folder. Look for lines like: For CSS: <code> wp_enqueue_style( ... ); </code> For JS: <code> wp_enqueue_script( ... ); </code>
Where are my js and css links in header?
wordpress
I want to add add_meta_box to specific page type like Page Template, Like Product Template. I am using this article http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/ to try it.
If your custom page template filename is <code> foobar.php </code> , you can use <code> get_post_meta() </code> : <code> global $post; if ( 'foobar.php' == get_post_meta( $post-&gt;ID, '_wp_page_template', true ) ) { // The current page has the foobar template assigned // do something } </code> Personally, I like calli...
How to add add_meta_box to specific Page Template?
wordpress
I created a child theme "my-theme" . In style.css I wrote nothing just the mandatory details I wrote there. <code> /* Theme Name: my-theme Theme URI: http://example.com/ Description: Child theme for the Twenty Twelve theme Author: Bhuvnesh Author URI: http://example.com/about/ Template: my-theme Version: 0.1.0 */ </cod...
One does not simply throw <code> &lt;link&gt; </code> (CSS) or <code> &lt;script&gt; </code> tags into the <code> &lt;head&gt; </code> of a WordPress theme. The right way to do it: Register, enqueue ... tadaa! WordPress has the "Dependency API" for this task. It consists basically out of those public functions: <code> ...
how to call files in child theme?
wordpress
Update I got it to fire using the following curl command: <code> curl -H "Accept: application/json" -X POST http://localhost/wordpress/wp-admin/admin-ajax.php -d "action=vixo_wordpress_signon&amp;data=banjometer" --trace - </code> Not really sure how to work out to get it to accept json, but hey... Original Question I ...
You have nothing specific to do to "load" modified php code in Wordpress. All files are just loaded as is at execution time (ie when the HTTP request is processed by the server). You just have to verify that your plugin is active. Your curl command is malformed. Use this instead : <code> curl -X POST http://localhost/w...
WordPress Ajax Problems
wordpress
Is it possible for a specific blog post (in wordpress) to be the landing page? For example my domain name is www.overflowingstupidity.com and I have this blog entitled post "How to burn your house down in 3 easy steps" Whenever a user clicks or type in the url bar of the web browser my domain name, he/she will directed...
Edit the blog post and copy the contents. Create a new page and paste that content. Make sure you use the same title. Now Go to http://www.overflowingstupidity.com/wp-admin/options-reading.php Click A static page and choose your blog post.
A Specific Blog post to be assigned as the landing page of my wordpress blog
wordpress
I’d like to know how to use the <code> get_bloginfo( 'template_directory' ) </code> tag in an external JS file. I just found out that it’s possible using the <code> wp_localize_script </code> function but I didn’t manage to get it to work … functions.php <code> wp_enqueue_script( 'custom_js' ); wp_localize_script('cust...
It doesn't work because you haven't enqueued your script properly. If the script isn't printed, neither are the variables set by <code> wp_localize_script </code> . Please read a WP Codex entry on <code> wp_localize_script </code> function. You have to include a path to the script after the handle.
Using template tags in external JS file
wordpress
I'm a little confused as to best practise for saving multi-select values in meta fields. Assuming <code> &lt;select multiple name="_casestudypost[]"&gt; </code> is my form field if I store $_POST['_casestudypost'] in a meta_key of the same name? (which returns an array) - how can I find out when 281 is in that array. I...
An <code> IN </code> query is not a string comparison query. It is more like a bunch of <code> OR </code> statements. <code> ... WHERE tablename.animal IN ('cat','dog','ferret') </code> is going to be the same as <code> ...WHERE tablename.animal = 'cat' OR tablename.animal = 'dog' OR tablename.animal = 'ferret' </code>...
Multiple Values stored as array in Meta Query
wordpress
I want to add a space between a Chinese character and a letter or a number to make the article more readable. For example: Google与Apple展开的专利大战在2天之前结束。 Google 与 Apple 展开的专利大战在 2 天之前结束。 But add the space manually is a hard work. How can I do it automatically? Maybe with CSS?
Interesting question. This could be a useful part of a stackexchange-url ("specific language file"). It cannot be done in CSS, because CSS is (mostly) character agnostic. But using a filter and PHP it is possible and on topic: <code> add_filter( 'the_content', 't5_chinese_spacing' ); function t5_chinese_spacing( $conte...
Add whitespace between Chinese and other letters
wordpress
i have one WordPress blog/site and want to point/map more than one domain name hosted/parked on my server. How do i do that * without redirecting by .htaccess? * Edit Im configure the related setting in cpanel or plesk in parked domain but wordpress dont recognized them. I want to know why cant i confure thet easy as c...
You can use a predefined constants that points to site URL. (from Codex ) <code> define('WP_SITEURL', 'http://example.com/wordpress'); define('WP_HOME', 'http://example.com/wordpress'); </code> Small example <code> define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST']); define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST'])...
A Wordpress site with more than one domain name / Parked domains
wordpress
This is my case. Supposing in my plugin dB table I have the following stored field name and values: <code> argument_1= 'test' argument_2= 'test2' </code> And I want to add a new string query string variables to all links going out to www.example.com such that it will look like this: If homepage is accessed: <code> www....
Sorry I read your question wrong. You probably want to use WP_Rewrite and do something like: <code> add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' ); add_filter( 'query_vars','my_insert_query_vars' ); add_action( 'wp_loaded','my_flush_rules' ); // flush_rules() if our rules are not yet included function my...
Add query string variables to all hyperlinks URL matching a specified domain
wordpress
this may be a step too far but I publish occasional tutorials on my personal blog and sometimes in comments get asked questions where an image would be very helpful to include as the answer. I've done a plug-in search and also looked for code but come up with nothing. Is there any way I can allow those with Admin role ...
The easiest and quickest way that you can do this is by downloading the Comment Images plugin and limit access to the upload feature by the function current_user_can . As the WP page demonstrates, use: <code> if ( current_user_can('manage_options') ) { // Plugin code here } </code> I had a very quick look at the plugin...
Allow admin roles to add images to comment replies
wordpress
I have been googling around but could not find the "add tag to post" api/codex. Does anyone know what it is ? Also, the "delete tag from post". Thanks.
You'll find an index of a good chunk of the WordPress API here on codex . The function you want is wp_set_post_tags() , but follow the links from that page to related functions. Edit: this should remove a tag from a post, per comment below <code> // $post is your post object, e.g. from: global $post; // $target is tag ...
Add tag to post api wordpress
wordpress
Fist I was using default option of permalink and everything was fine (speed is ok, my own created theme is working fine) but now I change default structure to post name structure of permalink now I am not getting 404 error but the problems are : 1 - Whole website is loading very slow (pages,post) . 2 - My custom theme ...
What are you typing in the <code> src="xxxxxx" </code> ? Do you have the absolute path or relative path to your style? If your not loading the CSS from your functions.php with <code> wp_enqueue_style </code> you should load it like this in your header to always get the correct URL to the file: <code> &lt;link rel="styl...
Styles are not loading when changing permalink to %postname%?
wordpress
I am looking for a function that will toggle text exactly as shown by pressing the "Phone" button on this website . Any help would be much appreciated.
I do not think you need any AJAX here, You can do this also using jQuery Slide method. http://docs.jquery.com/UI/Effects/Slide Try here http://www.w3schools.com/jquery/jquery_slide.asp http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_slide_down
AJAX function needed (toggle text)
wordpress
Tags are a major part of my platform. Using the default search, if the search term matches a tag, on the results page, I want it to display: <code> &lt;p&gt;Are you looking for our &lt;a href="TAG-URL"&gt;TAG-Name&lt;/a&gt; page?&lt;/p&gt; </code> The tag must have at least one post attached to it, so no empty tags. Wh...
In functions.php: <code> function wpse82525_link_search_to_tag() { // check if search archive is being displayed if( ! is_search() ) return; // get search query var $sqv = get_query_var( 's' ); // get tag base $tagbase = get_option( 'permalink_structure' ) ? get_option( 'tag_base' ) ? trailingslashit( get_option( 'tag_...
Add relevant tag to search results
wordpress
I have a multisite installation running WP 3.5. My main site and a few other blogs on the network work fine. However, if I register a new user and site, that user gets the "You do not have sufficient permissions to access this page." error any time they try to visit the admin panel of the site. The front end of the sit...
I spent several hours of my Saturday looking for this error. I could not find a guide anywhere on the 'net that described my eventual solution. Here is my solution. In the WP core, the "You do not have sufficient permissions to access this page." error is generated at the end of <code> /wp-admin/includes/menu.php </cod...
Troubleshooting a "You do not have sufficient permissions to access this page" error
wordpress
here is the code : <code> add_shortcode ('get_menu_child','get_menu_child'); function get_menu_child ($att) { global $wp_query; $thePostID = $wp_query-&gt;post-&gt;ID; $output = ''; $output .= '&lt;div class="childbutton"&gt;'; $output .= wp_list_pages("echo=0&amp;child_of=5&amp;exclude=".$thePostID.""); $output .= '&l...
ok, found the answer here : http://codex.wordpress.org/Function_Reference/wp_list_pages#Exclude_Pages_from_List here is the core of the answer : Markup and styling of page items By default, wp_list_pages() generates a nested, unordered list of WordPress Pages created with the Write > Page admin panel. You can remove th...
Extra title output with this function wp_list_pages
wordpress
probably tough to describe: I have a <code> custom-post-type </code> called <code> wr_event </code> and a custom-field for it called <code> event_date </code> . I have a lot of posts and each of those posts has set an <code> event_date </code> . Pretty straight forward. All I'd like to do now is list all the years in w...
something like this should do the job: <code> global $post; $years = array(); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); $this_year = get_post_meta( $post-&gt;ID, 'event_date', true ); if ( $this_year = date( 'Y', $this_year ) ) { if ( ! in_array( $this_year, $years ) ) { $y...
Get post-meta value of all custom-posts - lowest to highest year-count?
wordpress
I've been wanting to make the most out of WordPress, to use it more and more like a CMS as it truly is a wonderful project. Out of all the CMS/Blogging webapps, WordPress wins in my book. I understand how to create a post-type. What I don't understand is how to make pages within the dashboard, and how to add a sidebar ...
WordPress isn't built with your idea in mind. That being said, add_menu_page on the WordPress Codex shows how to create an admin top-level menu page, i.e., a menu item within the left column of the admin section. add_submenu_page shows how to create submenus of top-level menu items. You could create a plugin , and add ...
How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?
wordpress
My Wordpress admin interface shows there are 4 pending comments, but I've already approved three and deleted one of them via Disqus comment moderation page, but the page they were posted on was later deleted. I then posted two comments myself on a test page, deleted the page, and they are still shown as pending on Word...
You may want to try the next plugin: http://wordpress.org/extend/plugins/delete-all-pending-comments/ Note: I haven't tested this plugin reproducing your issue exactly, but the plugin I created to delete all pending comments. Please let me know :)
Wordpress admin bar showing pending comments which cannot be selected or modified after deleting parent page
wordpress
I'm using advanced custom fields and have setup an image field for my users to add an image in their profile. I'd need to display this image on post pages, so i've tried the following... <code> &lt;?php $attachment_id = the_author_meta('author_logo'); ?&gt; &lt;?php echo the_author_meta('author_logo'); ?&gt; &lt;?php w...
From codex : The the_author_meta Template Tag displays the desired meta data for a user. If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop. If the meta field does not ex...
Get author custom image field URL to display on post page?
wordpress
I'm using this great [tuts+ tutorial][1] for creating theme options page. It works great for me be beause I need to change background images of divs via css. It works great with one image but I dont know how to make it work with 2 images? It would be a huge help if you can tell me what I'm doing wrong here? Thanks! <co...
I can't comment on your code, but you might find this link useful: Options Framework Theme: http://wptheming.com/options-framework-theme/ This is something you have to edit carefully, but it has pretty much every type of control you can think of in there. It also had the only working MCE Editor that I could find. I wan...
Upload images - Theme options
wordpress