question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm trying to adjust the comments screen for non admins to my project. Right now I'd like to disable Quick Edit | Edit | History | Spam under any comment left for any post created by the user. Thanks!
This is done filtering the <code> *_row_actions </code> . For the Comments screen ( <code> /wp-admin/edit-comments.php </code> ) this is the hook: <code> add_filter( 'comment_row_actions', 'comments_row_wpse_92313', 15, 2 ); function comments_row_wpse_92313( $actions, $comment ) { if( !current_user_can( 'delete_plugins...
Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
wordpress
I've figured out how to implement pagination into WordPress archives, etc.., but the content isn't being returned correctly. Instead of /2013/01/ returning January 2013's archives, it instead returns the latest posts. My code is below: <code> &lt;h2&gt;&lt;?php echo wp_title('',TRUE,'right'); ?&gt;&lt;/h2&gt; &lt;ul&gt...
Don't use <code> query_posts </code> in the template for simple modifications of the main query. Use the <code> pre_get_posts </code> action instead to modify the query before it runs: <code> function wpa_date_posts_per_page( $query ) { if ( !is_admin() &amp;&amp; $query-&gt;is_date() &amp;&amp; $query-&gt;is_main_quer...
Why doesn't /2013/01/ properly return January's archives in archive.php?
wordpress
Can someone suggest me an idea on this? I am using Wordpress MU. And as per my requirement every user who register on main site will have a sub-site for them. And it is working correctly. I noticed that whenever a new site is created it is creating few tables in the database as like wp_2_post, wp_2_postmeta and so on. ...
Yes, this is the correct behavior, and no, there is nothing you can do about it in a multi-site setup. But that's usually not a problem; disk space is cheap. Maybe you could run a workaround with a single-site installation and rewrite rules to map subdomains to URLs like <code> /author/post-name/ </code> . But that sou...
more tables created when create a new site
wordpress
Much like the "edit" link when viewing a post, is here a "copy post" function I can include with my theme?
Yes, Duplicate Post is what you need. You have the function that you need in http://wordpress.org/extend/plugins/duplicate-post/other_notes/
Is there a way to create a "copy post" link?
wordpress
I’m doing up a photography theme in WP at the moment, and I’ve already got great help on stackexchange-url ("this thread") (thanks Milo!) for a previous question. In that thread, I asked about displaying the file name of an uploaded file on the <code> attachment.php </code> page for that file. I’m now using the suggest...
You could use <code> substr() </code> Returns the portion of string specified by the start and length parameters. in combination with <code> strrpos() </code> Find the numeric position of the last occurrence of needle in the haystack string. Example <code> $name = basename( wp_get_attachment_url( $post-&gt;ID ) ); echo...
Hiding or removing file extension displayed in HTML on attachment page
wordpress
I'm trying to translate Woosidebars strings in french using PoEdit but my french strings are never shown on the front-end. English strings are always displayed, even when I change the language (And I can see it works since other plugins strings are well translated). I've created and added a french translation file call...
I've finally found why this strange thing was happening on my website. It appears there was a conflict with the WPML String translation module which was already installed and configured to translate widget strings. <code> fr_FR.po </code> file was never called because the WPML plugin was configured to use database tran...
Translate Woosidebars plugin strings
wordpress
I am new in PHP and WordPress and I am personalizing an existent template and I have the following problem. In the function.php file of the template I have the following function: <code> function admired_posted_on() { printf( __( '&lt;span class="sep"&gt;Posted on &lt;/span&gt; &lt;a href="%1$s" title="%2$s" rel="bookm...
There is no specifier in your sprintf, so it won't output anything. Try: <code> sprintf('Views: %d', get_PostViews(get_the_ID())), </code> You may have to use %s instead, it depends what your get_PostViews function is returning.
Some problems calling a function into sprintf() inside functions.php template file
wordpress
I've been looking to grab a list of custom taxonomies for a custom post type with the titles, descriptions and tag but have not been able to progress or find anything helpful. Breakdown : I have registered a custom post type 'submissions' I have registered a custom taxonomy 'award-category' that is specifically for the...
Here's how you can output all the custom taxonomies in any template for examination: <code> &lt;pre&gt; &lt;?php $args = array( 'public' =&gt; true, '_builtin' =&gt; false ); $taxes = get_taxonomies( $args, 'objects'); foreach ($taxes as $key =&gt; $tax) { $terms = get_terms( $tax-&gt;name, array('hide_empty' =&gt; fal...
Retrieve Custom Taxonomies with Description and Slug
wordpress
I've never worked with serialized data... I need a little help with how to load "text" widgets title and content in php script outside wordpress... my script just connects to database (including wp-config and using its values). secont thing is to load wp_options entries with option name <code> sidebars_widgets </code> ...
Use PHP's unserialize function: <code> &lt;?php $data = 'a:2:{i:0;s:12:"Sample array";i:1;a:2:{i:0;s:5:"Apple";i:1;s:6:"Orange";}}'; $unserialized = unserialize($data); echo '&lt;pre&gt;'; print_r($unserialized); echo '&lt;/pre&gt;'; ?&gt; </code> Result: <code> Array ( [0] =&gt; Sample array [1] =&gt; Array ( [0] =&gt...
accessing wordpress serialized data outside wp
wordpress
I created a custom field called 'Page Description' which I use to create a custom title for each static page of my wordpress site. I use the code: <code> &lt;?php echo get_post_meta(get_the_ID(),'Page Description',true); ?&gt; </code> in my header.php. it displays in all of my pages except for my blog page. Can someone...
Try using: <code> &lt;?php // Determine context $page_id = ( 'page' == get_option( 'show_on_front' ) ? get_option( 'page_for_posts' ) : get_the_ID ); // Echo post meta for $page_id echo get_post_meta( $page_id, 'Page Description', true ); ?&gt; </code> What's happening: You're using a static page as front page, and a s...
Custom fields won't display on my blog page
wordpress
In the attached screenshot you can see the structure of the theme options we are working with. There are 8 tabs and for each tab, we have created custom fields using code similar to what can be seen below.This is how we are setting the default values for each field. ( ie. default = ' http://facebook.com/samplefacebookt...
Don't initialize defaults, or do an initial save. Just use sane defaults. For example, define an array of defaults: <code> function wpse92323_get_option_defaults() { $defaults = array( 'slug1' =&gt; 'default1', 'slug2' =&gt; 'default2' ); return apply_filters( 'wpse92323_option_defaults', $defaults ); } </code> Then, w...
Settings API - save multiple tabs at once
wordpress
Ok, so I'm totally confused on this and am looking for help. I have a site that is loading really slowly. I tracked the source of the slow load time is this call right here: <code> &lt;script type="text/javascript" src="http://googlecloud.my.phpcloud.com/do.js"&gt; &lt;/script&gt; </code> Funny thing is that it's getti...
Thanks for the help. In this case, it looks like it's an issue with the supercache plugin. When it wasn't activated, the code isn't added. When it's activated, the code is added. Still not sure how or why it was added, but at least It's not showing up now.
Weird Code Being Added to Wordpress Site [Thesis]
wordpress
I have a big network with subdomains (many of which use domains). I thought about solving this problem with cookies but after some research I don't think that crossdomain cookies is a best Idea. So I imagine this happing by saving in users meta some array of blogs and then displaying them on main page. I came across up...
Thank you for your attantion, I made it working with update_user_meta Here is my little function I wrote <code> global $blog_id; $current_blog_details = get_blog_details( array( 'blog_id' =&gt; $blog_id ) ); if (is_user_logged_in()) { $user = wp_get_current_user(); $last_visited_blogs = get_user_meta($user-&gt;ID, 'las...
Save users last visited blogs within whole network
wordpress
I noticed today that my error logs are littered with this information. I'm not quite sure what's causing it. Has anyone seen this before? <code> [Mon Mar 25 17:24:23 2013] [error] [client] PHP Warning: Invalid argument supplied for foreach() in /var/www/html/mysite/wp-admin/includes/plugin.php on line 1290, referer: ht...
This is most likely caused by a plugin. Deactivate them all, and reactivate one by one.
What's causing this error? "Warning: Invalid argument"
wordpress
I've been able to disable all the meta boxes for non admin in their backend but I'm having problems with Facebook AWD All in one which creates a widget seen by all the users when they create new posts. How can I disable it? Is there some sort of command that is good for any widget created by plugins that I can add in m...
You can try to add this line to your code example for the <code> admin_menu </code> filter: <code> remove_meta_box('awd_fcbk_awd_mini_form_metabox', 'post', 'side'); </code> where <code> awd_fcbk </code> is the plugin slug. Edit: This is the metabox that I'm targeting from the plugin source code: <code> //Like button m...
How to hide a plugin metabox for non admins when a user adds a new post
wordpress
For a custom jquery menu I'd like to show all submenus and hide / show each on demand. However my problem is to show all submenus in the first place. As of now I am managing the first level through the admin menu section: adding menu items to primary menu. Display works like so: <code> wp_nav_menu( array ( 'sort_column...
Ok, the problem in my solution was the use of <code> $menu_item-&gt;ID </code> instead of <code> $menu_item-&gt;object_id </code> . So the full correct logic is like so: <code> function print_sub_menus() { global $post; // get current page $post_id = $post ? $post-&gt;ID : -1; $has_post_parent = $post &amp;&amp; $post-...
Display all submenus
wordpress
This is my code: <code> wp_enqueue_script('ms_ajax_localized'); wp_localize_script( 'ms_ajax_localized', 'MS_Ajax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ), 'nextNonce' =&gt; wp_create_nonce( 'myajax-next-nonce' )) ); </code> I popped it into my <code> functions.php </code> Bashing my head against the wall...
I tested that code like this: <code> wp_enqueue_script('jquery'); wp_localize_script( 'jquery', 'MS_Ajax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ), 'nextNonce' =&gt; wp_create_nonce( 'myajax-next-nonce' )) ); </code> And it works but throws a <code> Notice </code> . It should be hooked to <code> wp_enqueue...
Can't seem to get wp_localize_script to work
wordpress
I recently noticed that Wordpress tries to auto-complete a URL when it's not submitted in its entirety. E.g. I have a post URL that looks like this: <code> http://www.mysite.com/some-post-title </code> If I browse to the following URL: <code> http://www.mysite.com/some-post-ti </code> I can see that the URL is submitte...
I believe that is the <code> redirect_canonical </code> function hooked to <code> template_redirect </code> . You should be able to disable it with: <code> remove_filter('template_redirect', 'redirect_canonical'); </code> But you should really think about whether you want to do that as it is fairly complicated and perf...
Disable Wordpress URL auto complete
wordpress
I migrated my WP deployment from the old server to the new server. The site still has the same URL (i.e. http://my.site.com ) but I've moved my WP deploy from the site URL to a subdirectory of said URL (i.e. the WP deploy used to be found at http://my.site.com , but now it's at http://my.site.com/blog ). The good news ...
It's a bit odd that there are root-relative URLs, WordPress by default uses absolute URLs when inserting images. However, probably the quickest fix is to open the SQL file in a text editor and just search and replace <code> src="/wp-content/ </code> with <code> src="/blog/wp-content/ </code> , or the absolute URL, what...
How do I mitigate the forward slash problem for URLs of images after a WP migration?
wordpress
I want to add relevant posts at the end of each of my posts page with an image in my newly created website http://www.techberita.com But being a beginner this is a great problem for me as I can't do that as I don't have that much knowledge of PHP and wordpress. I search out for plugins but couldn't find a good one for ...
This plugin sounds like what you're looking for. It uses post tags to find all relevant posts. Upload it to your plugins directory and activate it. Then just decide where you want it on your site and add post tags to get content to relate to each other. http://wordpress.org/extend/plugins/igit-related-posts-with-thumb-...
Adding Relevant Post Images
wordpress
I am writing a child theme with Blogolife as its parent. (I'm doing it on a local server, so can't show you the actual page). I have made several changes to the CSS in the child theme's "style.css" file. Up until this point, all those changes showed up fine. However, I am now trying to get rid of a quotation mark image...
You have to set a new background or the one defined in the parent stylesheet will be applied. <code> background-image: none; </code> Image and color are not mutually exclusive, so both just deleting the <code> background-image </code> line or/and defining a <code> background-color </code> won't change a background imag...
some things in child theme css not overriding parent
wordpress
I have a loop where I display all posts on the site, the problem is that the_excerpt is not being displayed. What am I doing wrong? <code> &lt;?php $all_posts = get_posts(array('numberposts' =&gt; -1)); $total_posts = count($all_posts); $posts_per_column = intval($total_posts / 3); $count = 0; $col = 1; foreach($all_po...
You need to be using <code> setup_postdata </code> <code> foreach($all_posts as $post): setup_postdata($post); // the rest of your loop </code> If you look at the docs for <code> get_posts </code> you will see that in all of the examples.
the_excerpt not displaying
wordpress
Within a post I can use <code> the_author() </code> to retrieve the author name, but in the sidebar of a single-post page this does not return anything. How to get metadata on the post author outside the post?
Test whether on a single post. If so, get a user object by the current posts' author ID and echo its <code> display_name </code> property: <code> if ( is_single() ) { global $post; $author = get_userdata( $post-&gt;post_author ); echo $author-&gt;display_name; } </code>
Cannot retrieve author in sidebar of single.php
wordpress
What I'm trying to achieve is a simple text-replace functions, that would be available to any site in my Wordpress Network. Basically I want to: Change <code> [--] </code> into <code> &amp;mdash; </code> (&mdash;), Be able to link to my own posts using only their titles -- <code> [internallink post=title] </code> or an...
To have a Network enabled shortcode, you only need a Must Use plugin . Just create the folder <code> /wp-content/mu-plugins </code> and drop your code there. From the Codex: Always-on, no need to enable via admin and users cannot disable by accident. Can be enabled simply by uploading file to the mu-plugins directory, ...
Global, network-wide shortcodes or text replace functions
wordpress
How can I post last posts from custom_taxonomy? I tried this like, but it doesn't works. <code> $terms=get_terms('tax_name'); $request=array(); if(count($terms)&gt;0) { foreach($terms as $t) { $request[]=$t-&gt;slug; } } query_posts( array( 'tax_query' =&gt; array( 'taxonomy' =&gt; 'tax_name', 'field' =&gt; 'slug', 'te...
First you really shouldn't use <code> query_posts </code> for that use get_posts or WP_Query and second <code> tax_query </code> accept an array of arrays from the codex: tax_query takes an array of tax query arguments arrays (it takes an array of arrays) so: <code> $terms=get_terms('tax_name'); $request=array(); forea...
Last posts from custom taxonomy
wordpress
I am using the roots theme. Inside scripts.php, the stylesheets are loaded using the wp_enqueue_style-function. <code> wp_enqueue_style('roots_bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', false, null); wp_enqueue_style('roots_bootstrap_responsive', get_template_directory_uri() . '/assets/css/...
I don't think you want <code> get_stylesheet_uri </code> , which will return the complete stylesheet URL including <code> style.css </code> . You want <code> get_stylesheet_directory_uri </code> , which will give you the path up to the child/parent theme stylesheet directory but not the trailing <code> style.css </code...
get_stylesheet_uri returns wrong path
wordpress
I've been trying to figure this out all day now. Consider the following code below: <code> &lt;div class="slider"&gt; &lt;div class="slides"&gt;&lt;?php wp_reset_query(); if(have_posts()) : while (have_posts()) : the_post(); if(is_sticky()) : ?&gt; &lt;div class="slide"&gt;&lt;a rel="bookmark" href="&lt;?php the_permal...
If you look at that code carefully, the only thing it ever prints are sticky posts: <code> if(is_sticky()) : ?&gt; &lt;div class="slide"&gt;&lt;a rel="bookmark" href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php echo the_post_thumbnail('full'); ?&gt;&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;&lt;/a&gt;&lt;/div&gt; ...
Why does this loop only work on the homepage?
wordpress
I have a custom post type <code> portfolio </code> and now I'm trying to enable navigation for the template where 10 portfolio items are shown. I'm using the following code to query the posts: <code> if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query...
The problem is that the page is named is the same as the <code> custom post type </code> , this is not possible in WordPress unfortunately. You could solve this issue by changing the page its <code> slug </code> .
Custom post type navigation - 404 on page 2
wordpress
Can you guys help me with some examples so i can sort out the thumb posts from a specific category (EXAMPLE) to not be shown for not logged users, instead to be shown an image which tells them that they have to be logged in order to see that post. Logged users can see all thumb posts. I tried to have this question shor...
You can hook a filter to the <code> post_thumbnail_html </code> and check if its a post in that category and if the user is not logged in ex: <code> add_filter( 'post_thumbnail_html', 'my_post_image_html_wpa92119', 10, 3 ); function my_post_image_html_wpa92119( $html, $post_id, $post_image_id ) { $category_to_exclude =...
How to not show post_thumbnail from specific category for not logged users
wordpress
I'm building user profile page where users could update their profile on the front-end. User profile is extended with a few custom fields, like 'Twitter', 'Facebook' and 'City'. The following code successfully updates all user details except the <code> dCity </code> : <code> $user_fields = array( 'ID' =&gt; $current_us...
wp_update_user &amp; metadata <code> wp_update_user </code> updates records in the *_users table. It isn't meant to update custom metadata in the *_usermeta table. Hence your "problem" is actually expected behavior. The <code> $userdata </code> argument passed to <code> wp_update_user </code> can contain the following ...
wp_update_user doesn't update and update_user_meta does
wordpress
I'm not good at sql queries so the question is: How do I list all the Posts where logged in user has left the comment? I guess it's kinda obvious that redundancy is unwanted in case user posted multiple comments to the same Post. Thanks!
It should be simple since comments are stored with a user_id if they are created by a logged in user and if not then its set to false so all you need to do is select the post id from comments that are made by user_id bigger the zero, something like this: <code> function get_posts_with_loogedin_user_comments(){ global $...
Fetch all Posts where logged in user has commented
wordpress
I use these codes to print custom field query. My custom field key is <code> out_wiki </code> <code> &lt;?php if( get_post_meta($post-&gt;ID, "out_wiki", true) ): ?&gt; &lt;div class="outlink"&gt; &lt;a href="http://en.wikipedia.org/w/index.php?search=&lt;?php echo get_post_meta($post-&gt;ID, "out_wiki", true); ?&gt;" ...
to store multiple values in same custom field key and print them at once If you want to store it as site option, you can use <code> update_option() </code> : http://codex.wordpress.org/Function_Reference/update_option Example 1: <code> // some array to store: $items=array('yellow','orange','green'); // save the array u...
How to use multiple query with same meta key
wordpress
I am not sure how relevant this is,i am working with Java based web-application, so in some cases we need to define some properties which can be used in entire web application like Google API Key Any other such key value We tend to define a property file with extension .properties and than JAVA API provide a way to rea...
You certainly could define those values as PHP constants and/or global variables in, for instance, functions.php . I understand you would, at this point, rather go with a "file based approach" than using the database, but nonetheless, I have to mention that that would be both the standard as well as the best way of doi...
How to read configuration file in wordpress or PHP
wordpress
I have a site that requires a lot of styling for post formats, I have never dealt with formats before but essentially what I want is : if post format is image... do this loop, if format is standard show The problem is that I am using a filter in the loop on single.php to pick out the image posted and show it as a heade...
I'm pretty sure you'd define the custom post formats in functions.php, then they'd reference their own PHP file which contains the loop you'd need. So for example, Text format would go to <code> post-text.php </code> , Image format <code> post-image.php </code> , etc. You could add your match filters into a function wi...
Filter image and text from post format
wordpress
I have been trying to reset my admin password for my local install of wordpress running on MAMP. Previously had been working fine but I forgot the password but when I go through the process of 'Lost your password' I am meant to get an email with new password but it never arrives in my hotmail (also checked the junk) I ...
Probably you dont have any mail server installed/enabled (like sendmail/qmail/postfix) in your local machine. You can still reset your admin password from database. The table "wp_users" stores the password in the "user_pass" field You can just replace the value with a md5 hash value of your desired password for the adm...
Forgot password not working
wordpress
I've created a custom profile field for my BP users and I'm looking to show the value on the user's profile page. The code below does this... <code> &lt;?php bp_profile_field_data( array('user_id'=&gt;get_the_author_meta( 'ID' ),'field'=&gt;'birthday')); ?&gt; </code> ...But it displays it as "1985-10-30 00:00:00". How...
I have no idea if BuddyPress has built in date functions but WordPress does and PHP does . This should do it: <code> $bpress_date = bp_profile_field_data( array('user_id'=&gt;get_the_author_meta( 'ID' ),'field'=&gt;'birthday')); // $bpress_date = "1985-10-30 00:00:00"; // test echo date('F, j, Y',strtotime($bpress_date...
Format Buddypress Date Picker Output
wordpress
The following code <code> &lt;?php previous_post('%', '&amp;#60;', 'no'); ?&gt; &lt;?php next_post('%', '&amp;#62; ', 'no'); ?&gt; </code> returns these links, as it should <code> &lt;a href="post_address/"&gt;&lt;&lt;/a&gt; &lt;a href="post_address/"&gt;&gt;&lt;/a&gt; </code> My question is about adding a class and ti...
<code> previous_post </code> and <code> next_post </code> are deprecated. you should be using <code> previous_post_link </code> and <code> next_post_link </code> . That function applies the <code> {$adjacent}_post_link </code> filter. You can use that to get what you want. A very, very crude example: <code> function co...
How to add a class and title attribute to the link generated by next/previous post
wordpress
Is there a way to scale up post thumbnails on Wordpress? On a featured div I want a post thumbnail/featured image with 584×348 px . When I upload a smaller image as a featured image on a post, it won’t scale up to this size. If the image is 250×250, it will appear 250×250. But if I use a larger image as featured image ...
As WordPress thumbnail generator doesn't do this "scale up" thing, you can do it using the following CSS rule: <code> .featured_thumb img{ width:100%; height: 100%; } </code> Hope it will help.
How to scale up post thumbnails/featured image?
wordpress
I've got a custom post type that has hierarchical taxonomies set up. For an example, my post type of "project" has categories of <code> A A.1 B C </code> I'm trying to get the taxonomies displayed as classes on <code> &lt;li&gt; </code> items for each post, but I just want the top level parents shown. For the post I'm ...
Thanks to help from @Bainternet (here, and also his input which led to the stackexchange-url ("answer in this question")), I was able to scrape together the code. <code> // determine the topmost parent of a term function get_term_top_most_parent($term_id, $taxonomy){ // start from the current term $parent = get_term_by...
Get only parent terms from wp_get_post_terms
wordpress
Before I ask this question, I know there is a (legitimate) hesitation to answer questions here about Woo products since they have their own support and their users should be encouraged to use that. I am a paying Woo user but couldn't solve this with their paid support, and my question is about overriding classes in WP ...
There's actually a filter that you can use, see <code> abstract-wc-email.php </code> , line 214: <code> return apply_filters( 'woocommerce_email_recipient_' . $this-&gt;id, $this-&gt;recipient, $this-&gt;object ); </code> you can put the following in your functions.php: <code> add_filter( 'woocommerce_email_recipient_c...
Adding a second email address to a completed order in WooCommerce
wordpress
I am trying to get the value of a custom field. The trick? I'm in the loop, currently printing out 2 of 5 for this example. I would like to get some info from 3 of 5 (or even 1 of 5) while printing out info on 2 of 5. I hope that makes sense. Any help would be great!
As you posted no code and little in the way of exactly what criteria you are using, I can't really writ functioning code but inside your Loop try: <code> var_dump($posts[$wp_query-&gt;current_post -1]-&gt;post_title); </code> That is, <code> $posts[$wp_query-&gt;current_post -1] </code> is the previous post. You can ch...
Collect Data from NEXT item while in loop
wordpress
When users upload very large photos and memory is tight, it seems like Wordpress runs out of memory - fails to resize the uploaded photos and does not create the necessary metadata ( <code> _wp_attachment_metadata </code> entry in <code> wp_postmet </code> a is not created). The worst part is that the user is never not...
How do your users upload photos? You're right about <code> register_shutdown_function </code> . It seems to work well in my code, though I only ever call my back-end via AJAX (I've also got file upload functionality), and so only need to account for this case. Here's how I set it up in my plugin. Outside of the plugin ...
Out of memory error reporting
wordpress
I'm writing this question having already found a solution, in order to see whether other people have encountered this problem. I was having a problem on the back end of a site I am building in wordpress in which all the jquery scripts that I tried to load using the native wordpress handles (i.e. jquery-ui-core, jquery-...
From this OP comment: although the site itself deregisters the main wordpress jquery handle and the re-registers it to point to the google cdn verrsion That is your problem. The problem isn't an issue with WordPress 3.5 per se, nor is it a problem with Plugins. The problem is that you're deregistering the core jQuery v...
'jQuery is not defined Error' appearing in load-scripts.php
wordpress
I'm building a random workout generator on Wordpress to help with my fitness, and am stuck at saving random post arrays for later reference. I'll explain. The generator should work in two main stages: You choose how hard you want the workout to be, and how long it should take. These values are passed to a new page via ...
My suggestion is to store the workouts as a new entry inside the particular user's meta data. » Saving a single workout Suppose the workout consists of the exercise IDs <code> 1, 3, 5, 9 </code> . Then the code is: <code> // this is the current workout $workout = array(1, 3, 5, 9); // get the current user $user = wp_ge...
How can I save an array from a random post sequence for later use?
wordpress
on my Wordpress site on the first page I always get my posts displaying however when I navigate to my 'Blog' page with my blog template attached to it I cant get my posts to display here. I used a wordpress function to echo out the current page template on the first page and it is getting the index.php template. My blo...
From the "Settings" menu in the wordpress admin panel Select the "Reading" options and select your blog page for "Posts Page" from the dropdown beside it, see the screenshot here http://d.pr/i/h4nV Hope it will help
Blog posts not displaying
wordpress
I am pretty new in WordPress blog and I am developing a blog with this template: http://scorejava.com/wordpress351 As you can see at the top of the page there is a "menù" that only show the page in the site (at this moment: "Home" and "Pagina di esempio"). This menù is showed by the following lines of code into the hea...
You need to edit functions.php andding the following line <code> &lt;?php register_nav_menu( 'primary', 'Primary Menu' ); ?&gt; </code> Then go in admin section Apearence-Menus and create one menu In the header replace <code> &lt;?php wp_list_pages('title_li=&amp;depth=1'); ?&gt; </code> for example (the primary menu) ...
How to add menù section to my WordPress template?
wordpress
I'm looking for a way to check that a post has a minimum word count before allowing it to be sent for review (added to the pending post status). Below is the code I have: <code> if (current_user_can('contributor')) { function minWord($content){ global $post; $num = 150; //set this to the minimum number of words $conten...
Those transition post hooks run after the post is saved . You will have to interrupt the process earlier. I would hook to <code> wp_insert_post_data </code> . <code> function minWord($data){ if (current_user_can('contributor')) { $num = 150; //set this to the minimum number of words if (str_word_count($data['post_conte...
Minimum Word Count Before A Post Can Be Made Pending Review
wordpress
My question is: it is possible to change the background color (for exemple) to an article who is categorized under "quote" format. (or whatever format like Aside or Link)? I want that an article in Quote format appears different from others, with a specific font color, or specific background color. Is that possible? Th...
Targeting the whole page First, ensure that you're calling <code> body_class() </code> inside of the HTML <code> &lt;body&gt; </code> tag: <code> &lt;body &lt;?php body_class(); ?&gt; </code> Then, you can take advantage of the post format-specific classes output by <code> body_class() </code> to style according to you...
Twenty Eleven theme, how to change style to a specific "format"
wordpress
I recently copied the tables from a live WP install to a dev site for that same site. I've changed all the prefixes, the site/WP URLs, and the salt values. I can successfully log into the new dev site, but the admin account (not actually named admin) does not have admin privileges. Once I log in and am redirected to th...
So you've duplicated the tables in the DB, with the new set having the dev_ prefix? In that case, the problem is probably that you have not updated the fields within the duplicated tables that inherit that prefix. For instance, dev_usermeta will now have a meta_key called wp_capabilities. This needs to be dev_capabilit...
"sufficient permissions" error for admin after duplicating WP database to new install
wordpress
I am already using a small code to set default sort orderby a custom field called "Year" I need to add another orderby to also sort by "Post Title" in the same sort. Sort = Year-Customfield (DESC) and Post-title (ASC) Following is the code I'm currently using to sort by Year DESC. <code> add_filter('pre_get_posts', 'so...
You could try using the <code> posts_orderby </code> filter: <code> add_filter('pre_get_posts', 'sort_arc'); function sort_arc($q) { if ($q-&gt;is_category() &amp;&amp; $q-&gt;is_main_query()) { $q-&gt;set('meta_key', 'the-year'); add_filter('posts_orderby', 'custom_posts_orderby'); } return $q; } </code> where <code> ...
Add multiple orderby with pre get posts
wordpress
I'm adapting a script I found online to add custom bulk actions to the screen with the list of posts. It has this line: <code> add_action('load-edit.php', 'custom_bulk_action'); </code> I'm trying to adapt it for the media library. I see that in place of <code> edit.php </code> I should use <code> upload.php </code> , ...
If you want to use your code, try this: If you want to check if the medias are attachments, you can try to use <code> $_REQUEST['detached'] </code> <code> add_action( 'load-upload.php', 'export_media_test' ); function export_media_test() { if ( ! isset( $_REQUEST['action'] ) ) return; echo 'Export Media'; if ( isset( $...
How to make custom bulk actions work on the media/upload page?
wordpress
I want to use wordpress content in external mobile app. I need an URL address to get content from function located in <code> functions.php </code> for example: <code> function test() { return 'it works'; } </code> What I need is an url address ( <code> http://example.com/something </code> ) which will return a value fr...
You can check for the presence of a specific query variable, so <code> http://www.example.com?my_listener=test </code> . You check for this on the init hook and if it isn't there you just quit early and WP goes about it's business. If it is there, you can then do something, just don't forget to exit at the end or the f...
Function in functions.php by url
wordpress
Given vX and vX+1, how do I find the difference between each versions database schema?
In <code> wp-admin/includes/upgrade.php </code> are version specific functions for database upgrades. They include changes for the schema. Examples for 3.4.0 and 3.5.0: <code> /** * Execute changes made in WordPress 3.4. * * @since 3.4.0 */ function upgrade_340() { global $wp_current_db_version, $wpdb; if ( $wp_current...
Where can I find the database changes between WordPress versions?
wordpress
I'm developing a plugin and I wanted to allow users to just subscribe to a custom user level without having a password sent to them via email. this level will not be able to contribute to the site, so just reading capability. I will use this subscription to add the email to a mailing list and to allow the user to buy o...
If you're just wanting to add them to a mailing list, you really don't need to create a user account for them. Just use something like this: http://wordpress.org/extend/plugins/mail-list/ or Gravity Forms to capture their email addresses. The fact that you then say "to allow the user to buy on this website" seems to su...
Is it possible to have users register without having a password?
wordpress
I want to be able to highlight the most recent post in a list of recent posts. By highlight I mean bold or style slightly differently from the other posts. This is the code I use now: <code> &lt;h2&gt;Assignments&lt;/h2&gt; &lt;ol&gt; &lt;?php $recentPosts = new WP_Query(); $recentPosts-&gt;query('showposts=15&amp;cat=...
I found a better solution: <code> &lt;h2&gt;Assignments&lt;/h2&gt; &lt;ol&gt; &lt;?php $recentPosts = new WP_Query(); $recentPosts-&gt;query('showposts=15&amp;cat=188&amp;order=DESC'); ?&gt; &lt;?php while ($recentPosts-&gt;have_posts()) : $recentPosts-&gt;the_post(); ?&gt; &lt;?php $ageunix = get_the_time('U'); $days_...
How to highlight most recent posts in a list
wordpress
I have been using the advanced custom fields plugin and very much appreciate its abilities. I have a page on the website i'm working on called About Us and within that page, there is contained, a list of staff members (4 in total). I built this list of staff members using the add on repeater field in the advanced custo...
Rather than outputting all rows, you can check each row in a loop and only output it if something matches. In this example, there's a <code> treatment </code> field within the repeater that is the value of the name of the treatment post. If the two match, output the other values: <code> $other_page = 89; $practioners =...
How to share specific data contained in repeated fields across multiple pages
wordpress
In a theme I am working there are up to 3 Stylesheets. I am using the hook 'wp_enqueue_scripts'. The order of the stylesheets is important for overwriting styles. I have a code like this: <code> add_action('wp_enqueue_scripts', 'add_stylesheet_one', 10); add_action('wp_enqueue_scripts', 'add_stylesheet_two', 14); add_a...
The problem is that your actions are being run in the order you perceive but the styles are just being collected by WordPress and included in a random order. The order of your add_actions will not be important. I would do this: <code> function add_all_stylesheets() { // you omitted this from your question, see below } ...
Hook 'wp_enqueue_scripts' priority has no effect
wordpress
I searched for a solution for this problem, but cannot find an answer (or exact replica of the problem) Basically, I set up Multisite on MAMP Pro (Apache port 80, MySQL Port 3306). The set up was smooth, and I created a new site via a subdirectory. The parent theme loads fine. I created a child theme, and it activates ...
Basically I am using a child theme as the default theme every time a new blog is created. In the wp-config.php file - I was calling <code> define('WP_DEFAULT_THEME', 'confit-childtheme'); define( 'TEMPLATEPATH', '/public_html/wp-content/themes/confit'); </code> I read that when you are using a child theme as the defaul...
Child Theme activates, but nothing from parent theme displays (MAMP, Multisite)
wordpress
This is related to this stackexchange-url ("other question"), I tried with <code> get_posts </code> , <code> pre_get_posts </code> , <code> WP_Query </code> and basically every option I could find for 2 days now, no solution yet. The full problem in hand: I have 2 post-types, <code> articles </code> and <code> news </c...
You can use <code> WP_Query() </code> with <code> paged </code> array key to pass the current page number: <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' =&gt; 'articles', 'posts_per_page' =&gt; 4, 'paged' =&gt; $paged ); $articles = new WP_Query($args); /////...
Query specific number of posts for each post type in specific order
wordpress
I need to force a 404 on some posts based on conditions. I managed to do it ( although I don't know if I did it the right way) and I'm a getting my <code> 404.php </code> template to load as expected. My code: <code> function rr_404_my_event() { global $post; if ( is_singular( 'event' ) &amp;&amp; !rr_event_should_be_a...
You could try the Wordpress function <code> status_header() </code> to add the <code> HTTP/1.1 404 Not Found </code> header; So your Code 2 example would be: <code> function rr_404_my_event() { global $post; if ( is_singular( 'event' ) &amp;&amp; !rr_event_should_be_available( $post-&gt;ID ) ) { global $wp_query; $wp_q...
How to force a 404 on WordPress
wordpress
I have a custom post type called cars. There is a taxonomy brands. I have a template single-cars.php and I'd like to add a link to the brand page(The category). Assume I'm on the page of the post Passat 2013. The brand is Volkswagen. I'd like to show the permalink of the brand Volkswagen. My setup: functions.php <code>...
<code> get_the_category() </code> only works with the default taxonomy, per the Codex page ; you probably need to use <code> get_the_terms() </code> instead. So you'd replace your <code> get_the_category() </code> call with <code> get_the_terms( $post-&gt;ID, 'brands' ); </code> , if I'm not mistaken.
WP the_posts() on single-cars.php get category link
wordpress
I'm trying to find the best approach to customising the edit post screen for a custom post type. I want to add a button which, when clicked will trigger code which looks up an external (not WP) database, gets some data, and then updates various fields - both core WP fields and custom meta fields. Ideally, the updates s...
Add the Javascript code below to your submit button. This should remove the event that provides the warning. Please note that this code is untested. <code> window.onbeforeunload = null; </code> This should disable the property however as stated above this code is untested. Cheers, Joe
Updating post content and custom fields in edit post screen
wordpress
I know there a some functions already avaible here for this task, but none of them seem to work as needed. The best way seems to me adding a filter to wp_handle_upload_prefilter like stackexchange-url ("kaiser") does in stackexchange-url ("this example"). Unfortunately the file only gets the parent-post-title if the po...
After trying to add a function to <code> publish_post </code> and creating a lot of unnecessary files I tried to blemish stackexchange-url ("kaisers function") to fit my needs. <code> function modify_uploaded_file_names( $image ) { // Use part of the post or user object to rename the image get_currentuserinfo(); global...
rename attachments based on parent-post-title on upload
wordpress
I've inherited a theme from a another developer that I've re-styled for a client. We're just about finished, but I thought I'd run it through the Theme-Check plug-in to see if there's any errors or problems. Unfortunately there's a ton. I've gotten rid of most of them, but I have one Required left: <code> REQUIRED: Cou...
What it does <code> post_class </code> adds classes to the posts on a post by post basis, usually adding them to some kind of post "wrapper". This allows for the targeting of posts with CSS rules according to various criteria-- category, tag, sticky, format, etc. That is, theme authors, plugin authors, and individual u...
Theme Check: Could not find post_class
wordpress
I created an archive page called archive.php Here I include header / footer and this code: <code> &lt;?php if (have_posts()) : while (have_posts()) : ?&gt; &lt;h1 class="entry-title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;a/&gt;&lt;/h1&gt; &lt;?php the_post(); the_content(); ?...
You have to call <code> the_post(); </code> before you use <code> the_permalink() </code> or <code> the_title() </code> . Both functions work with a global <code> $post </code> object that will be set up by <code> the_post(); </code> .
Archive - same title for the first two posts
wordpress
I have created password form where visitors can access any password protected post with belonging password. Basically you enter unique password and you are redirected to a post which is protected with given password. Everything works fine (with help from s_ha_dum), except one thing - you have to enter password twice. f...
Here ya go: <code> function dopasswordstuff(){ if(isset($_POST['homepagepassword'])) { global $wpdb; $post_password = trim($_POST['passwordfield']); $post_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare("SELECT ID FROM $wpdb-&gt;posts WHERE post_password = %s", $post_password) ); if (!empty($post_id)) { if ( empty( $wp_hashe...
Storing password (functions.php)
wordpress
I'm running Theme Check on a theme I've inherited and I've come across lots of recommendations like this one: <code> RECOMMENDED: Text domain problems in loop.php. The twentyten text domain is being used! </code> The site has no plans for being translated, so what's the best thing to do in this situation? Replace every...
You can remove all the translation references if you don't plan on translating it. You can also leave it in place, it shouldn't hurt anything.. If you want to remove it, go through your theme files and find references to <code> __(' Your Text', 'Domain') </code> and just change it to the "Your Text" portion. (Sometimes...
Should all references to a text domain be to my current theme?
wordpress
Is there a way to call <code> wp_editor </code> for a meta box using just the text/HTML mode without TinyMCE. I think the deprecated function pre-3.3 did this but I'm not sure how its done now.
Yes, it's possible to set it to false. The full parameters list is in the file <code> wp-includes/class-wp-editor.php </code> . These are the default values for the <code> $settings </code> array when calling <code> wp_editor( $content, $editor_id, $settings ); </code> : <code> array( 'wpautop' =&gt; true, 'media_butto...
wp_editor in text mode only(without TinyMCE)
wordpress
On my page I've got a query that retrieves posts with specific parameters and I'm displaying one post per page with pagination. I've figured out how to get the total count of posts found by the query. I want to add some navigation that essentially says "You're looking at 'n' of 25 posts" and have 'n' increase or decrea...
You have all the necessary variables already at hand: <code> $page </code> is the current page number, and <code> $portfolio-&gt;found_posts </code> the total number of posts. Both should be integers, but to be sure and to keep the code translatable I would use something like this: <code> $current = sprintf( _x( 'Page ...
Determining what post is displayed out of total posts found
wordpress
I'm trying to get the hang of custom post types and I am trying to get them to loop through the post types within a page template. I'm already using the MultiEdit plugin to display certain content regions within my template. Overall, here is what my template page looks like: <code> &lt;?php /* Template Name: Home Templ...
Looping through posts First of all, you need to have two separate loops - one for whatever it is that it's displaying right now and second one for your custom post type. Right now the block where you want your custom posts to appear is located within the first loop, and that's not good. I suggest that you read up on Th...
Using custom post types within a section of a template
wordpress
I'm currently want to develop my design company website and choosing wordpress as my CMS. How do I should install the wordpress when I want the domain structure like this: Blog = blog.example.com Portfolio = example.com/portfolio/... Shop = shop.example.com = using WooCommerce I'll be glad if someone would help, becaus...
If you want sections in a subdomain and in subdirectories, use a multi-site installation. See Create a Network and our tag multi-site . Then you set the the blog and the shop as separate sites, and the <code> portfolio </code> as a custom post type or as a regular page in the main blog.
Subdomain and subdirectories together in one installation
wordpress
I run a wordpress blog with a syntax highlighter plugin ( Crayon ). The plugin highlights code between pre tags, example: <code> &lt;pre class="lang:languageid" title="example"&gt; some code &lt;/pre&gt; </code> Wordpress sometimes replaces characters suchs as <code> " &amp; &lt; &gt; </code> with html entities which a...
Both answers are not the full solution, seems that if I combine them I am very close (just need to fix the replace part). The regex from @hasinhayder answer seems to work well in the plugin that @nathanpowell suggested. There is no way to split points, stackexchange-url ("common best practice") seems to be to combine b...
replace html entities in posts between pre tags
wordpress
I have configured multi-site wordpress. I have some sub-sites as like site1.mydomain.com and site2.mydomain.com . Now i just want to enable the user registration on my sub-sites. When a user clicks on register link in any sub-site (site1.mydomain.com or site2.mydomain.com) it takes them to the main site (mydomain.com) ...
What you've described is default behavior for WordPress where when a user registers on a subsite, they're really registering with the root site. Check out this plugin, which looks to help with new user sign ups and adding them to the right subsite. http://wordpress.org/extend/plugins/wpmu-default-user-role/ If that plu...
User registration on sub site
wordpress
My idea is that the visitor enters the password on a page and than the wordpress post with belonging password load if there is one. Here is the code: Form on page: <code> &lt;form method="post" action=""&gt; &lt;input type="password" name="passwordfield"&gt; &lt;input type="hidden" name="homepagepassword" value="1"&gt;...
Here is all you need to make this work, plus your actual form of course: <code> function dopasswordstuff(){ if(isset($_POST['homepagepassword'])){ global $wpdb; $post_password = trim($_POST['passwordfield']); $post_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare("SELECT ID FROM $wpdb-&gt;posts WHERE post_password = %s", $pos...
Password form redirection to belonging post
wordpress
I was wondering if it's really neccessary to keep the <code> &lt;div class="entry"&gt; </code> in the page.php file (or any other template for that matter). I typically use a blank HTML5 wordpress theme and it doesn't have any declarations within the CSS file for that class. So I just wanted to get other opinions on it...
No specific markup is required in a theme. The only exception are themes published on wordpress.org, they have to follow the guidelines . And even there, <code> &lt;div class="entry"&gt; </code> is not required. The only parts you have to use are these: <code> while ( have_posts() ) { the_post(); print '&lt;h2&gt;' . g...
Do I really need the div class entry?
wordpress
I know there are a lot of hooks in WP for altering a posts content (and other fields) before the post is written to the DB upon saving; but what I am interested in doing is running my custom filter before the post is loaded for editing . So basically when my custom post type is loaded by /wp-admin/post.php?post=##&amp;...
You can use the <code> the_editor_content </code> filter: <code> function wpa_editor_content( $content ) { global $post; return "this post's id is $post-&gt;ID " . $content; } add_filter( 'the_editor_content', 'wpa_editor_content' ); </code>
Filter post before *editing*
wordpress
I have created a page called mysite and have permalink as /XXX/wordpress/mysite ‎ On this page I am creating a calendar. The calendar is working little wierd. It is working for a current year but when on clicking next or previous button as soon as it switches to next or previous year calendar gets disappear and show fo...
I Got it.... I just changed year to year1 and it worked :) Don't know what was the problem :)
Using calendar and page does not show calendar for next or previous year
wordpress
I wrote a function, which should rename my attachments, based on the post title. Unfortunately this function created over 10.000 empty instances in my media-library, before I was able to stop it. The instances are all attached to a single post, which I could delete if it's necessary. I'm really sorry to bother you with...
Since I didn't expected an answer to this question I tried it with wp_delete_attachment(); . I wrote this function on a random page of my site (since the site isn't live yet) and executed it from there. <code> $attac_kill_ids = range(1235, 22686); //fill an array with the post_ids from the empty instances foreach( $att...
bulk deleting empty items in the media library
wordpress
Is it possible to enqueue scripts and css only to the Network Admin Dashboard? To edit the network admin menu, you have this hook: <code> network_admin_menu </code> , so I also tried <code> network_admin_enqueue_scripts </code> , but this didn't work. Thanks! Roc.
You can use the global variable <code> $current_screen </code> . It has the property <code> is_network </code> , with a boolean value, that indicates if we are in <code> /wp-admin/network/ </code> or not. <code> add_action( 'admin_print_scripts', 'network_scripts_wpse_91699' ); function network_scripts_wpse_91699() { g...
Possible to enqueue scripts and CSS to Multisite Network dashboard?
wordpress
I am very news in WordPress world and I am finding some difficulties with creation of a personal template. I want implement a blog like this one (that is using WordPress): http://viralpatel.net/blogs/ My blog have to be simplest and there must be only two columns: one for the last posts and one for the most visited pos...
If I understand you... Your theme may only have an <code> index.php </code> and a <code> single.php </code> but WordPress supports a much more complicated templating system , and you can control the formatting of different types of content just by creating files with the right names. In your case, I think that at least...
How to differentiate the homepage structure from the category page structure in WordPress template?
wordpress
I have a special case where I'd like to order posts in a custom order and it would be great to use the "menu_order" field that is normally only used for pages. What would be the best way to expose that in the WordPress admin UI?
Apparently it's as easy as: <code> add_action( 'admin_init', 'posts_order_wpse_91866' ); function posts_order_wpse_91866() { add_post_type_support( 'post', 'page-attributes' ); } </code> And then doing the query: <code> $order_posts = new WP_Query(array( 'post_type' =&gt; 'post', 'post_status' =&gt; 'publish', 'orderby...
How to use "menu_order" field for posts?
wordpress
I did not find any useful tips from google search and I wrote the same question in wordpress forum but there is no reply I am writing the complete step here First step I am redirect page to custom post archive page add_action( 'template_redirect', 'plu_redirects' ); //I am saving in the session the post_id which is the...
Instead of using $_SESSION variables we'll register a query variable. <code> function wpa_91718_query_var( $vars ) { $vars[] = 'event_page'; return $vars; } add_filter( 'query_vars', 'wpa_91718_query_var' ); </code> Then we can modify the query before it is run using <code> pre_get_posts </code> . If I understood you a...
Wordpress Rewrite Url with arugments
wordpress
I am using NextGEN Gallery and NextGEN GalleryView . (Editors Note: Not sure what this sentence means) But I can't get the image those image was hidden. When I check the css and js files, all of file are included when I check in firebug the below error is shown: <code> jQuery.timer is undefined ...for: http://192.168.1...
The GalleryViews plugin hasn't been updated in a while. jQuery has changed a lot since then. You'll most likely need to either downgrade jQuery (not recommended by any means) or upgrade the plugin's JavaScript to work with later versions of jQuery. It looks like there aren't newer versions of the scripts so you may hav...
JavaScript Errors when Loading NextGEN Gallery
wordpress
My code is the following: <code> &lt;?php get_header(); ?&gt; &lt;div id="main-content"&gt; &lt;section id="primary"&gt; &lt;!-- &lt;h2 class="cat-title"&gt;Latest news&lt;/h2&gt; --&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;article class="post"&gt; &lt;img src=""&gt; &lt;h2 clas...
I believe wp_list_comments needs to be inside the loop. If not, you need to pass an array of comments to it. You are doing neither of these. Either move it inside your loop, or call get_comments() (as Johannes rightly points out) and pass the returned array from that into wp_list_comments as the second argument. You al...
Comments are invisible, what's the problem with wp_list_comments?
wordpress
I'm searching for half an hour now on how to get the url/permalink base in Wordpress (the 'category' and 'tag' value set in the backend). Could you please point me in the right direction? I want to dynamically print the following - but only replace the <code> tags </code> and <code> category </code> part (not the tag/c...
You really shouldn't need this, as you should be outputting the URLs via the API: <code> get_tag_link </code> , <code> get_category_link </code> , <code> get_term_link </code> . However, for the sake of answering the question, they're stored in options: <code> get_option( 'tag_base' ); get_option( 'category_base' ); </...
How to get the url to tag & category base set by the user?
wordpress
I recently implemented Woocommerce and in trial session I found following issue: 1. Initially, I provide 10qty for Product1. 2. place a Dummy Order from front-end of 10qty of that Product1. 3. Then After that I see Product1 is Out of Stock. 4. From Admin of woocommerce, If I cancelled that dummy order or reduce the pro...
Sorry to Trouble this Slept world of Wordpress. I got My answers From Awaked wordpress world,directly from Author of Plugin here: http://ilikekillnerds.com/2012/07/the-problem-with-woocommerce-its-crap/
Auto Stock Update after Order cancel from Admin of Woocommerce?
wordpress
I have 2 levels of categories ( one sub-category only. No <code> sub-sub </code> category ). I need to get all sub categories without parent category. (I don't want to specify any parent category.) Example: <code> p_cat1 s_cat1 s_cat2 p_cat4 p_cat3 s_cat4 s_cat5 s_cat7 </code> from here, I need <code> s_cat1 s_cat2 s_c...
You could use <code> get_categories() </code> . Returns an array of category objects matching the query parameters. Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax. <code> // Fetch parent categories $parent_categories = get_categories( 'parent=0' ); foreach ...
get all sub categories without specify any category
wordpress
In BuddyPress, What is the use of is_default_option field in wp_bp_xprofile_fields table?
This is one of the things you won't find in the docs, but only in the source. The source code contains only one usage of this variable. This is in bp-xprofile-template.php line 493. <code> // First, check to see whether the user-entered value matches if ( in_array( $allowed_options, (array) $option_values ) ) { $select...
BuddyPress: What is the use of is_default_option field in wp_bp_xprofile_fields table?
wordpress
I have a page, let's called it "Artists", that displays a list of posts in a custom post type, again "artists". How can I redirect pepole who visit the Artists page to the first post in the "artists" post type?
This is assuming that your page 'Artists' has an ID of 10, so change that as necessary. You can also amend the <code> $args </code> array as you wish to better suit your needs, if required. Here is the Codex for <code> WP_Query </code> , which shows that parameters that you can use. Finally, this needs to go right at t...
Redirect page to first post in custom post type
wordpress
I've got a multisite installation of WP 3.5.1 running, and I'd like to for users to be able to embed screencast.com videos into posts, preferably with a shortcode like you do with YouTube or Vimeo. I can do this using the full embed code from the screencast.com sharing menu, but I can only do this as a super admin. All...
Screencast.com has a dedicated GitHub page with hands full of tutorials (no need to clone them over here). You can then utilize <code> wp_oembed_get() </code> or register a new provider using <code> wp_oembed_add_provider() </code> . <code> echo wp_oembed_get( 'http://example.com', array( 'width' =&gt; 1920, 'height' =...
Embedding screencast.com Videos in WordPress Multisite
wordpress
I'm trying to create a page which should display a list of users with the role "Author" only and exclude all other default and custom roles. I also want them to be filterable by alphabets, so if I click on "A", or "B", and so on, the users starting with that alphabet should show on the page. I tried to use wp_list_auth...
Alright, I've got a plugin here which sorts it out. amr users wordpress plugin
Display a list of users with avatar filterable with alphabets
wordpress
If I'm setting up a brand new multisite installation with WordPress in it's own folder (say /wp/) why can't I configure the network to use subdomains instead of subfolders? Currently, if I try to setup the network with the WordPress core in it's own folder I'm not allowed to choose between a subdomain-based or sub-fold...
I figured it out. The fact is, a network can use subdomains or subfolders, even when WordPress is installed in it's own folder as long as the main site's HOME URL is set to domain.com and not to the sub folder location . Here's an example: I setup a clean install of WordPress using Mark Jaquith's WordPress Skeleton whi...
Why can't a WordPress network (multisite) in it's own folder use subdomains?
wordpress
I found this script stackexchange-url ("Wordpress Media Manager 3.5 - default link to") and it works fine for me. But my problem is, that I have a custom wp_editor on the front end where I want it to work, but I can't find a way to activate it on this site.. Here is the code: <code> add_action( 'load-post.php', 'wpse81...
In your theme's functions.php file, or the like: <code> add_action( 'your-custom-action', 'wpse8170_media_popup_init' ); </code> In the page template used for the page in question: <code> do_action( 'your-custom-action' ); </code>
add_action on a specific page
wordpress
I'm doing up a photography site where each post is a photo project, and each post attachment will be displayed on its own attachment page (linked to from the main post page). On the attachment page, I want to give an email link, below the image. At the moment, the code is something like this: <code> &lt;a href="mailto:...
You can get the original attachment filename via <code> wp_get_attachment_url </code> : <code> echo basename( wp_get_attachment_url( $post-&gt;ID ) ); </code> or in the form of the example you provided: <code> &lt;a href="mailto:me@whatever.com?Subject=Image: &lt;?php the_title(); ?&gt; - &lt;?php echo basename( wp_get...
Adding attachment file name to email link
wordpress
I am developing a site that must be HTTPS secure and Wordpress is loading <code> &lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt; </code> at the very top of my page, before <code> &lt;html&gt; </code> and giving me an insecure error. I cannot find where this is being loaded from to prevent...
When I build themes, I also like to make the WordPress header as clean as possible and then reconstruct it to my own liking. The code below is excessive for your question, but it might help you with other 'WordPress inserted code' in the future. The key snippet of code you are looking for is <code> wp_deregister_script...
How to prevent Wordpress from loading the jQuery library at the top of the page
wordpress
WordPress does a 301 from <code> http://example.com/?p=100 </code> to <code> http://example.com/post-title/ </code> , but I thought a URL rewrite was different from a redirect and therefore this wouldn't result in a 301. Can anyone clarify?
A rewrite enables <code> http://example.com/post-title/ </code> to translate internally to the proper query vars to load the requested post. The shortlink does a 301 redirect to the pretty URL because it should not be possible to access the same content from more than one URI. This is so a search engine won't index the...
Rewrite vs Redirect from ?p={ID}
wordpress
I know there are a ton of post out there about how to allow html in profiles. Most of these warn about the security risk of doing so. My thinking is there has to be a way to only allow users to use html for certain users. I tried this but It doesn't work. I think it's because you can't remove a filter from inside a fil...
You can hook on an early action and apply the filter for your use case: <code> add_action( 'load-profile.php', 'allow_profile_html_wpse_91564' ); function allow_profile_html_wpse_91564() { global $current_user; if( '2' == $current_user-&gt;ID ) remove_filter('pre_user_description', 'wp_filter_kses'); } </code> The hook...
Allow Profile HTML for select users
wordpress
I want to add a page of content (a readme file) in the WordPress admin, I can't seem to find how to do this in the codex - can anyone point me in the right direction? It will literally just be a simple page with a few paragraphs of content.
You need just two steps: Hook into the action <code> admin_menu </code> , register the page with a callback function to print the content. In your callback function load the file from <code> plugin_dir_path( __FILE__ ) . "included.html" </code> . Demo code: <code> add_action( 'admin_menu', 'wpse_91693_register' ); func...
Adding a custom admin page
wordpress
I'm surprised this hasn't been asked before, but I couldn't find it via search. I'd like to do: <code> Full Category Name -&gt; Text in Menu Bar Exercise Tips -&gt; Tips Reviews of Exercise Equipment -&gt; Reviews Industry News -&gt; News </code> So the menu bar looks like: <code> Tips | Reviews | News </code> But when...
Actually this is pretty simple and straightforward: when you set up your menu (under Appearance > Menu ) you will find out you can add Categories there. After adding them, click on the down-pointing arrow on the right of the navigation element, it will give you the possibility to change the Label , while keeping the Or...
How do I rename a category in the menu bar only?
wordpress
How to use the <code> check_admin_referer </code> method with oop? If I use as it follows the function can not be called: <code> class MyClass{ function __construct(){ if( isset($_POST['my_nonce_field']) &amp;&amp; check_admin_referer('my_nonce_action', 'my_nonce_field')){ $this-&gt;update_item(); } } } </code> $test =...
<code> check_admin_referer </code> is a pluggable function which means it is defined after plugins are loaded so call your constructor or instantiate the object after or using <code> plugins_loaded </code> action hook. ex: <code> class MyClass{ function __construct(){ if( isset($_POST['my_nonce_field']) &amp;&amp; chec...
nonces in custom oop plugin
wordpress