question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
For my custom post type, I only want to have "Published" and "Draft" as the available options in the bulk edit and quick edit screens, i.e. I tried hooking on to the filter <code> quick_edit_dropdown_pages_args </code> but it doesn't seem to get fired. I inserted a <code> wp_die() </code> in my callback but the admin s...
Answering stackexchange-url ("this Question"), came to a jQuery solution to Ana Ban's one. <code> add_action( 'admin_head', 'wpse_56551_script_enqueuer' ); function wpse_56551_script_enqueuer() { global $current_screen; /** /wp-admin/edit.php?post_type=post /wp-admin/edit.php?post_type=page /wp-admin/edit.php?post_type...
How do I limit the status options for bulk/quick edit to only Published and Draft?
wordpress
How can I override a function in pluggable.php? I have tried making my own plugin -- got the fatal error on function already defined. I tried functions.php in my theme -- got the white screen. Is it possible to override a pluggable.php function without touching the source code file itself? Thanks. Here is the function ...
Wrap it in a <code> function_exists </code> check: <code> if( ! function_exists('some_pluggable_function') ) { function some_pluggable_function() } } </code>
How to Override a Pluggable Function
wordpress
I have a CPT with slug <code> function </code> (singular) and archive slug <code> functions </code> (plural). Permalink structure for: singular is <code> /function/[postname]/ </code> archive is <code> /functions/[page-x/] </code> . (can poke live at QueryPosts ) This works and looks fine, however I have logged some ca...
Hook into <code> '404_template' </code> . ( Example ) Fetch all public custom post types where <code> has_archive </code> is not <code> FALSE </code> . Find the post type’s <code> has_archive </code> string and see if it is part of the current request’s url. Try <code> get_page_by_title() </code> with the last part of ...
How to seamlessly redirect between different archive and singular slugs?
wordpress
I have a child theme based on the twenty ten theme which I am happy with except for one thing. My gallery posts (I am a photographer so the goal of my blog is pictures) do not show any images from the post on the main page. I want to have my main page be a list of recent gallery posts each of which should show the shor...
Instead of overriding the main loop, you can always just create a template, similar to the main loop and use that on a separate page (which you then set to display as your home page). You'd just need to set up a wp_query in that template to call the posts you want and run a loop on that. That way everything is left in ...
How do I override part of the main loop in my child theme?
wordpress
I'm trying to write a plugin that allows a user to upload a video to Vimeo through the Vimeo upload API. In order to avoid trying to upload a video to a potentially shared hosting account and then from there to Vimeo I am trying to upload directly to Vimeo through their POST availability - https://developer.vimeo.com/a...
It's not the right approach, since you are in a post(cpt) edit page the metabox's are simple grouped fields that get attached to the post form and in your case it's actually the browser who is filtering your metabox's form attributes and not WordPress since you are creating nested forms which is something that you just...
inside a metabox
wordpress
I have a WP blog with a few pages and posts and several categories. I want to write a loop to retrieve images attached to the posts (not the pages) and only those from a specific category and it's children. The category id is 60. This is the WP_Query call: <code> $my_query = new WP_Query( array( 'post_type' =&gt; 'atta...
You'll need to first grab the posts, then grab the attachments that are children of said posts. <code> $my_query = new WP_Query( array( 'meta_key' =&gt; 'my_hash', 'nopaging' =&gt; true, 'orderby' =&gt; 'meta_value', 'fields' =&gt; 'ids', 'cat' =&gt; '60', )); if ( $post_ids = $my_query-&gt;get_posts() ) { $post_ids = ...
How to run WP_Query to retrieve attachments to posts only from a particular category?
wordpress
How can I remove the category/taxonomy description field? The one which shows up on the edit category/taxonomy page.
When no hook is available, you can always count on the old jQuery trickery... <code> add_action( 'admin_footer-edit-tags.php', 'wpse_56569_remove_cat_tag_description' ); function wpse_56569_remove_cat_tag_description(){ global $current_screen; switch ( $current_screen-&gt;id ) { case 'edit-category': // WE ARE AT /wp-a...
Remove the category/taxonomy description field?
wordpress
I have a custom WP query that is returning every post, instead of just the ones being specified by the query. I can't seem to find anything wrong with the code, so I must be missing something: <code> //Process incoming variable if(!empty($_REQUEST['region'])){ $region = $_REQUEST['region']; } else { $region = NULL; } i...
Thanks for all of the help! It tured out to be a combination of issues: Instead of imploding the <code> $country_search_array </code> , it needs to be added as is to the query. Since it's an array, we can't use the <code> '=' </code> for the compare value. It needs to be <code> 'IN' </code> I couldn't have figured it o...
WP Query Returning All Posts
wordpress
On my home page I am trying to filter by a category type and limit it to one post; but I keep getting "no posts found". Here is my following code: <code> &lt;?php query_posts('cat=34&amp;showposts=1'); ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; </code>
Use <code> post_per_page </code> instead. Like this: <code> query_posts( 'cat=34&amp;posts_per_page=5' ); </code> Read more about the query on: WordPress Codex
Post not found when filtered by category ID
wordpress
Is it possible to dynamically get sidebar parameters from within a widget? That is, I am trying to access the <code> before_widget </code> / <code> after_widget </code> / <code> before_title </code> / <code> after_title </code> / <code> name </code> parameters of the containing sidebar. Suppose we have a sidebar regist...
The parameters are given (as an array) as the first argument provided to the <code> widget </code> method. The second argument, <code> $instance </code> , holds the options for that particular instance of the widget. My usual set up is: <code> function widget($args, $instance){ //Extract the widget-sidebar parameters f...
Get sidebar parameters (before_widget, before_title, etc.) from within a widget
wordpress
I've got some code that I want to turn into a function. It works great until I wrap it in said function: <code> $args = array( 'posts_per_page' =&gt; -1, 'post_type' =&gt; 'asset', 'category_name' =&gt; $cat ); $cat_query = new WP_Query( $args ); $matching_category_ids = array(); while ( $cat_query-&gt;have_posts() ) :...
Simple, you're addressing <code> $post </code> out of context. When you're running a standard WordPress loop, WP will load a global <code> $post </code> variable with the results of the current query. This includes the ID, title, content, post meta, etc. The loop functions will reference this global variable to actuall...
WP_Query in functions.php
wordpress
I just movde my site from a dev subdomain, to the root. I have extensive amounts of data saved in custom meta fields which I created with the WpAlchemy class . All of this data is not appearing in the site (back or front end), although it appears to be in the database. This happened right after attempting to use the se...
Been there done that. Try this: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ Its a search and replace tool that you put in your WordPress root and just run it from mydomain.dev/searchreplacedb2.php It fixes the serialization problem when you want to change the url:s to the live one.
After moving my site from a dev subdomain, to root, all my custom meta data is gone
wordpress
Using the below code: <code> &lt;?php if ( post_password_required() ) { ?&gt; &lt;form method="post" action="/wp-pass.php"&gt; &lt;p&gt;This content is password protected. To view it please enter your password below:&lt;/p&gt; &lt;input type="password" style="margin:10px 0;" size="20" id="pwbox-&lt;?php the_ID(); ?&gt;...
Figured it out! The new version of WordPress (3.4) changed the way the password protected pages worked. This should work for you now: <code> &lt;?php if ( post_password_required() ) { ?&gt; &lt;form method="post" action="/wp-login.php?action=postpass"&gt; &lt;p&gt;This content is password protected. To view it please e...
post_password_required() not recognizing cookie set with correct password
wordpress
Im trying to add a rewrite rule to make this mysite/?attachment_id=106 view like this mysite/series/106 Ive looked evetywhere in this site and others and its very confuse because there are lots of diferent ways to do it. Ive tried is editing functions.php file in my themes folder, adding this at the begining of the fil...
Place the code suggested below in functions.php of your desired theme, it worked for me with WP 3.4: http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/
add_rewrite_rule and attachment_id
wordpress
I need to access a page which is name 2011. The trouble is that WP thinks that I am trying to read the 2011 posts of my blog. The only way I can make it work for the moment, is to change the permalink of my 2011 page to be mypage-2011. Is there anyway I can make/force WP to use 2011 as permalink for the page 2011, so i...
First of all rewrite handling can become very complicated very quickly - particularly when your desired structure conflicts with WordPress' default behaviour. The best advice is probably to just avoid such conflicts rather than try to resolve them. With that as a premable... WordPress generates rewrite rules from vario...
Page permalink conflict with Date
wordpress
My brain has fallen over. How do I save this post data? Building some key-value pairs in the form. <code> for ($i = 1; $i &lt;= 3; $i++) { $saved = $meta[$i]; //print_r($saved); //echo $saved['key']; echo '&lt;p&gt;'; echo '&lt;label for="meta_k_'.$i.'"&gt;Key&lt;/label&gt; ', '&lt;input id="meta_k_'.$i.'" type="text" ...
This should be work: <code> foreach ($_POST['_meta'] as $value) { update_post_meta($post_id, $value['key'], $value['value']); } </code>
Save post meta foreach loop
wordpress
When a media (image) is uploaded and the subsequent images are created (all the different sizes), I would like to perform a few actions. It is simple and I basically need only the new attachment ID, that would be enough. Same during deletion: before or after deletion, I need to know which attachment ID is concerned. Th...
i guess you are looking for this <code> add_attachment </code> and <code> delete_attachment </code> example: <code> add_action('add_attachment', 'attachment_manipulation'); function attachment_manipulation($id) { if(wp_attachment_is_image($id)){ //do your own tasks } } </code>
Which filters or actions to use after a media upload and delete?
wordpress
I have a custom post type and I want to be able to control the order that the posts are displayed by defining the order in an array, and then checking the posts meta_value against the array to see where it should sit in the order of posts. Using the code below I can get the dealers who's 'Postcode' is one of the values...
I ended up querying each postcode separately then compiling the results into the $posts[] array using array_merge. This meant that the final $posts[] array contained all my posts in distance order and I could loop through it normally. I understand this is a really inneficient way of doing it and would appreciate if any...
Sorting posts by specific order
wordpress
I've seen code that looks like this: <code> get_posts(array('p' =&gt; $thumbnail_id, 'post_type' =&gt; 'attachment')); </code> What is the definition of the p parameter and is it documented anywhere? I can't find anything about it on the Codex page for get_posts().
'p' is for querying a post, as opposed to 'page_id' for querying a page. It's documented in the WP_Query codex
What is the p parameter in a get_posts() parameter array?
wordpress
I was wondering if it's possible to enqueue raw CSS as a string directly from within a template file? I'm writing a custom template for a page and need to add some style rules for it. What I want to do is write the styles out as a string var in PHP then use the enqueue_style function to load these styles, rather than m...
Yes and no. You can load a raw CSS string into the header programatically, but you can't use <code> wp_enqueue_style() </code> to enqueue it. That function specifically loads files into the header in <code> &lt;link&gt; </code> tags. But what you can do is something like this: <code> function print_inline_script() { ?&...
Is it possible to enqueue a raw CSS string directly from within a template file?
wordpress
I'm trying to get the ID of the oldest post with the <code> post_type = job_listing </code> and <code> post_status = publish </code> . I'm using the code below but it does not work. Could anyone please help me <code> $oldestID = mysql_query("select id from wp_posts where post_type = 'job_listing' and post_status = 'pub...
I do not see any problem in your query (except some poor query writing styles). You did not explain 'does not work'. what you get in return? do you get any errors? Probably you do not have any <code> published </code> <code> job_listing </code> ! However, here is how you can improve your given code: <code> $oldest_post...
retrieve the oldest post id
wordpress
I have made a plugin that uses the Media Library to allow users to upload files to a specific directory - using the <code> upload_dir </code> filter. I would like to know if there is a way (i.e. a filter) I can use to limit the media library to displaying only files contained within my custom folder? If possible, I wan...
A solution that works for me is to add a clause to the Wordpress query when the media library is being displayed. From browsing my Wordpress database I noticed that the full path to <code> wp_posts.post_type = 'attachment' </code> is stored in the <code> wp_posts.guid </code> column. <code> add_filter('posts_where', 'l...
Limit Media Library to Given Folder
wordpress
while there are plenty of social sharing / email a friend type of plugins i am looking for one that will let me place it on only 1 page and most importantly allow me to specify which URL (not necessarily the URL of the page the form/buttons are on) I would like to recommend. to explain: the site i am working on is sell...
I would recommend rolling your own. Use the sharethis api or addthis . Then you can use get_permalink(); for the url parameter. <code> function wpu_share() { $url = get_permalink(); $title = get_the_title(); $add_this = 'st_url="'.esc_url( $url ).'"'; ?&gt; &lt;span class='st_facebook_large' &lt;?php echo $add_this; ?&...
Social Sharing / tell a friend plug but specify which URL to share
wordpress
I'm a bit new to wordpress and php and I'm trying to create a site where users have the possibility to change the appearance of the index page for other visitors. This could perhaps be done with back-end access to a maintenance plugin but I want it to be more simple than that for the user. Basically just log in and the...
Based on Bainternet's answer to this question: stackexchange-url ("Save Theme Options (options.php) From The Frontend") The key is to know the name of the plugin option to Enable/Disable the Maintenance Mode. In this example, it's named: <code> my_maintenance_mode </code> <code> &lt;?php if ( isset($_POST['mmode']) &am...
How can I let users open the site for other visitors?
wordpress
How do you display or process HTML in a wrapped shortcode ? <code> [myshortcode]&lt;div class="map"&gt;&lt;/div&gt;[/myshortcode] </code> my shortcode code is <code> function myshortcode_sc($atts, $content = null) { extract( shortcode_atts( array( 'col' =&gt; 'left', ), $atts ) ); $output = '&lt;div class="span' . esc_...
Maybe try replacing <code> . do_shortcode($content) . </code> with <code> .$content. </code> ? Source: http://wp.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/
How to display html in a shortcode
wordpress
I have a client project that has posts assigned to their country of origin. The client wants to be able to search the posts by continent and or region. I have a separate table that assigns each country to its respective region, and I have the WP query that uses the resulting array: <code> $country_names = array('Englan...
I created a new template and started from scratch with it. I still can't get the new WP query to return any posts, but it did solve this initial problem. First I got my results: <code> if(!empty($_REQUEST['region'])){ $region = $_REQUEST['region']; } else { $region = NULL; } if (empty($region)) { echo "No region select...
Parsing External Table Arguments
wordpress
I wanted to update custom blog option created thru Settings Api using the function <code> update_blog_option </code> . I created this code. <code> $country_base = get_blog_option($blog_id, 'mytheme_options');//retrieve all options $country_base['country_base'] = $the_country; $currency_unit = get_blog_option($blog_id, ...
As per the Codex on update_blog_option : Switches to the blog id specified, runs update_option() and then restores to the current blog. If $refresh is true then it will refresh the blog details. Not tested, but I think your problem is trying to update elements of the array instead of the whole thing: <code> $the_option...
[Multisite]How can I update custom blog option?
wordpress
I'm seeing this quite often: No OS, same Browser, weird hostname -- they're definitely not real users. Can I do anything to take precautions before they do something? Thanks!
There's an app plugin for that, Limit Login Attempts . Some more info available in this wp beginner post: http://www.wpbeginner.com/plugins/how-and-why-you-should-limit-login-attempts-in-your-wordpress/
Brute force attack?
wordpress
I recently started using this nifty meta box framework: http://www.deluxeblogtips.com/meta-box-script-for-wordpress/ I really like the plupload meta box, however, I need to be able to add the uploaded image into the editor rather than just attaching it to the post. Any idea how I can create a button that inserts the co...
You can add content to the editor via javascript: <code> tinyMCE.activeEditor.selection.setContent('&lt;img src="hello.jpg"&gt;'); </code>
Insert attachments from custom uploader into post (regular uploader style)
wordpress
I would like to remove fields from the profile in Theme My Login . I want to remove everything except email and password field. I am able to hide fields using a little jQuery. But un fortunately I'm not good with it. Can someone help me how to make this? step by step? Update: I found this but i dont know how to use it:...
From the link I provided in the comments: All of the templates located within /wp-content/plugins/theme-my-login/templates are easily customizable. Just simply pick any template you wish to edit, copy it to your current theme’s directory and edit it as you wish . Theme My Login will always look for templates in your cu...
Removing Fields From the Profile Page of Theme My Login Plugin
wordpress
i've been searching for a while now on how to show Cubepoints Points and Ranks in bbPress replies right below the user avatar and name... Found the template file where to show the info, tho not sure this would be the correct one to grab the reply-author info, the "loop-single-reply.php" and just bellow bbp_reply_author...
I found the solution of the problem, it goes like this: <code> &lt;td class="bbp-reply-author"&gt; &lt;?php do_action( 'bbp_theme_before_reply_author_details' ); ?&gt; &lt;?php bbp_reply_author_link( array( 'sep' =&gt; '&lt;br /&gt;' ) ); ?&gt; &lt;!--Ranking --&gt; &lt;div class="bbp-ranking"&gt; &lt;span class="bbp-r...
How can i show Cubepoints ranks/points in bbpress replies
wordpress
I'm trying to put search results into a div with ajax. The issue is I'm getting errors saying <code> undefined function have_posts() </code> when the the search template is accessed. It also took issue with <code> get_header() </code> which was in the search-results.php but I took it out. Here's how I have it setup. <c...
When you load a template file directly that way, you're not loading the WordPress environment, so no WordPress functions are available. Your two options are to either load the search page on the front end and filter the result, like: <code> $('#results').load('http://mysite.com/?s=searchterm ul#target'); </code> Or bui...
Template issues getting ajax search results
wordpress
I created the page template which needs to take some GET variables, currently URL's looks like that: http://example.com/coupons/?cat_id=25 I need to make that way: http://example.com/coupons/25 I checked the WP_Rewrite documentation and playing a bit with that stuff, but can't make things work as except. Regards, Chris
First you have to filter query vars and add your query var to the array: <code> add_filter( 'query_vars', 'wpa56345_query_vars' ); function wpa56345_query_vars( $query_vars ){ $query_vars[] = 'cat_id'; return $query_vars; } </code> Then your rule which captures any digits after your pagename coupons and passes that as ...
Wordpress Rewrite Rules
wordpress
How i can create a welcome message area for my frontpage with backend control {admin panel} Welcome message
create a page theme then call it in index.php have_posts()) : $recent-> the_post();?>
Front page welcome message area
wordpress
I'm using a redirect plugin that adds rewrites to the permalink. I want to count views on the front-end since I can't hook into the single.php as a result. This seems to be close, but it isn't incrementing the views meta value. I'm not sure where to debug, or tr Here's my code so far: I'm copying most of this from the ...
Storing the href value and using the <code> window.location = redirect </code> line was the only way I could get it to work. <code> jQuery(document).ready(function($){ $('.external').click(function(e){ e.preventDefault(); var redirect = $(this).attr('href'); $.post(ajax_object.ajaxurl, {action:'inc_views',post_id:$(thi...
ajax front-end increment views on click
wordpress
I've hit some sort of stumbling bock here, and I can't find my way over it. I'm trying to craft a custom WP query that searches for posts by country of origin, selecting multiple countries at once. I have a table that maps countries to regions, so the initial query will search for the selected region, and return all of...
Try following codes: <code> $country_search_array = array(); while($row = mysql_fetch_array($regionresult)){ $country_search_array[] = $row['country']; // Your country field name } $country_search = "'".implode("',", $country_search_array)."'"; $args = array( 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( array( ...
Creating Custom Query
wordpress
How would I pull a single random image from custom post type "athletes" and the custom image field "athletethumbnail" to be displayed in my sidebar? (I have PHP enabled for my text widget on sidebar.)
If I get your question right, as you mention Tag in the title, but not in the Content - and also mention a random image but then it's not a library image but a custom field value... So, the following code will grab 1 random custom post type that has a custom field value that's not empty. And it's a mix of <code> get_po...
Random image from tag/custom type on sidebar
wordpress
I have a custom WP query that searches a single custom field, using an array. The custom field is for the country of origin of a post. The array I'm using are the names of the various countries in a region. The objective is to be able to return all posts from a region or continent. Here is my query: <code> $args = arra...
Thanks for all of the help! It tured out to be a combination of issues: Instead of imploding the <code> $country_search_array </code> , it needs to be added as is to the query. Since it's an array, we can't use the <code> '=' </code> for the compare value. It needs to be <code> 'IN' </code> I couldn't have figured it o...
WordPress Query Returning Every Post
wordpress
My primary navigation menu consists of pages, categories, and custom taxonomy. It appears to be in a random order. How do I adjust the order of the links? (the drag/drop in wp menus panel doesn't seem to have any effect)
Turns out under my theme (Bones) bottom position is actually the first one to display on front end. I had it backwards.
Change menu item order
wordpress
Where in my admin class should I place the action hooks for adding css, scripts and the add menu page? In the __construct? Or should they be placed in a method?
Since you are using OOP, you probably want to architecture your plugin more efficiently. This is fine, but you'll be the one to structure your classes and build them. So what if you put it in the __construct() function? That's fine, as long as you initiate a new instance of the class. Putting it in a method (private or...
OOP Plugin: Where should I place the action hooks in the class?
wordpress
On many sites ( particularly CMS style business sites) there are 2, 3 4 or sometimes more boxes usually containing a title, icon and some text. These appear under the header linking to strategic parts of the site. I have set up my custom theme so that the user can decide which parts of the site to link these boxes to v...
On my website, I've used Custom Post Types to achieve a slightly more complex version of what you're trying to do. My requirements were; Rich text on title JavaScript animation to flick between "Featured Items" (not covered here) Ability to edit the featured items easily from the back-end for admin users Ability to hyp...
Should I use custom menu, C.P.T. or theme options, or something else for this?
wordpress
Any way to limit the number of pages that are created automatically by paging? I would limit to five pages in all, authors, tags, categories ... Ex: "site.com/tag/news/page/5", "...author/admin/page/5." Thanks.
This seem to work. Put in your <code> functions.php </code> : <code> add_filter('pre_get_posts', 'limit_pages'); function limit_pages($query) { $query-&gt;max_num_pages = 5; if ($query-&gt;query_vars['paged'] &gt; 5) { $query-&gt;query_vars['paged'] = 5; $query-&gt;query['paged'] = 5; } return $query; } </code> But I g...
Limit the number of pages created by the paging
wordpress
I would like to delete (not allow) searches with certain keywords (eg "of", "a"). If the search is done using exactly these terms, do not return anything or redirect to 404 page ... Thanks guys.
Try this in your <code> functions.php </code> , and change <code> news </code> for whatever you want to be blocked in your site. <code> add_action('wp', 'check_search'); function check_search() { global $wp_query; if (!$s = get_search_query()) return false; if (preg_match('/news/', $s)) { $wp_query-&gt;set_404(); statu...
Do not allow to search certain words
wordpress
I need to do something specific in my <code> save_post </code> callback for bulk and/or quick edits, so how do I check the nonce for that? I can only find <code> _wpnonce </code> in the <code> edit.php </code> html source, but can't find an action to match it with. I also tried <code> check_admin_referrer() </code> (no...
I found <code> check_admin_referer('bulk-posts') </code> in wp-admin/edit.php:49 for bulk edit. With @Rutwick Gangurde's help, I found <code> check_ajax_referer( 'inlineeditnonce', '_inline_edit' ) </code> in wp-admin/includes/ajax-actions.php:1318. Thanks y'all.
How to verify nonce from Bulk/Quick Edit in save_post?
wordpress
I have this function where I call a custom function through the add_action hook: <code> add_action('publish_post', 'custom_function'); </code> ... now it works perfectly, but the I want the custom_function to be delayed so it runs AFTER the post has been published. BUT, if I add <code> sleep(20) </code> inside the <cod...
<code> publish_post </code> is called after post is published! So, you already got covered. but if you want to run an action after a certain time of the post is published, it's better to write a cron job. For example, if you need to run the function after 5 minutes of the post is published, you need to register a singl...
delay function on publish?
wordpress
I'm using this code: <code> &lt;?php wp_tag_cloud( array( 'taxonomy' =&gt; 'channels') );?&gt; </code> To display custom taxonomy as a cloud tag. How can display with all links being the same size? I can't seem to override the inline styles.
How about passing the <code> smallest </code> and <code> largest </code> arguments to <code> wp_tag_cloud() </code> and making them both the same? <code> &lt;?php wp_tag_cloud( array( 'taxonomy' =&gt; 'channels', 'smallest' =&gt; '1', 'largest' =&gt; '1', 'unit' =&gt; 'em', ) );?&gt; </code> Update: use <code> get_term...
Make tag cloud links consistent
wordpress
I recently saw a link titled "Donate to this plugin > " link on a WordPress theme (and then I did!). How is this added to a plugin's page on wordpress.org? Here's a screenshot:
It is read from the infos on your plugins readme.txt. Example from my Default Values for Attachments === Plugin Name === Contributors: moraleida.me Donate link: http://moraleida.me/ Tags: attachments, default values, caption, title, description Requires at least: 2.5 Tested up to: 3.3.2 Stable tag: 0.1 License: GPLv2 o...
"Donate to this plugin" for WordPress.org Plugin Authors
wordpress
I have three pages on my site (Listen, Read, Watch) which each query a different post category: "listen", "read", and "watch" respectively. I created three separate php files with their own unique template names and I created a Page in the wp-admin and selected the appropriate template for each. I am having trouble usi...
<code> cat </code> requires an ID, if you're using the slug, set <code> category_name </code> instead. see WP_Query Category Parameters .
Having trouble using this post category query on multiple pages?
wordpress
I have one server that has wordpress in the root directory. However before I installed wordpress, I also have (root)/videos. I'm sure I can move this folder anywhere, however I want to move it to a place so wordpress can add it to its media library. This way, I can easily select it. I don't want (and I can't) re-upload...
I did flag this question as a duplicate of this one: stackexchange-url ("Is there any way to add images to the Media Library through a path on the server?"). Which points to the plugin Add to Server as the article linked by @RyanB in the comments... But, wondering on the issue, a creative solution is uploading a bunch ...
What if I have a large file on the server that I want the wp library to have?
wordpress
The iframe in thickbox media library is not big enough to display my custom tab. I tried to add "width=900&amp;height=600" at the end of the link that pointing to the library, but no luck. How can I modify the inframe size?
Yep, it's curious that adding the extra parameters doesn't works... I know that Adminimize does that. Looking at its code, that's what it does: <code> wp_deregister_script( 'media-upload' ); wp_enqueue_script( 'media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array( 'thickbox' ) ); </...
How to enlarge thickbox media library iframe?
wordpress
I have a custom post type "product". I need to have its index accessible from the main menu, so i 've added a Custom Menu entry, simply stating "/works/" as url value. Problem is: if i'm looking at a single product, the main index menu link does not receive the current_menu_ancestor class. Any idea how to fix that? <co...
Put this in your functions.php: <code> function additional_active_item_classes($classes = array(), $menu_item = false){ global $wp_query; if(in_array('current-menu-item', $menu_item-&gt;classes)){ $classes[] = 'current-menu-item'; } if ( $menu_item-&gt;post_name == 'product' &amp;&amp; is_post_type_archive('product') )...
show current item in custom menu, when inside a custom post type
wordpress
New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at tutorials/guides, they say "simply add this function to the wp_head action or after_setup_theme". Without these tutoria...
Take a look at stackexchange-url ("Mike's answer to a similar question") more specifically the plugin he posted there can be used to create a list of all action hooks and filters that were called to generate that page in order of execution.
Too many actions/filters!
wordpress
I have just completed a website using WordPress as a CMS, the site has 6 people administering the content and in the couple of days before launch all 6 were updating the content. We found that if multiple people were editing/creating widgets at the same time this would save over and some of the widgets were deleted. I'...
I have never personally had this problem, but to the best of my knowledge WordPress does not have the system to support multiple users managing widgets at the same time, at least not widgets in the same widget areas. Is it a problem to just have one user at a time manage the widgets? I can't really imagine that being a...
Multiple users editting widgets
wordpress
I'm developing a WordPress plugin. I'd like to charge somewhat for it, because I'd like to be developing related things, for a living. I also want to make it easy for people to e.g. contribute patches and bug fixes. So I'm thinking about hosting the source code at GitHub. Does anyone host the source code for a premium ...
I have only ever hosted paid plugins on private Github repos. If you are fine with some users downloading the code for free from Github, then I wouldn't worry about it too much. Most "normal" (non developer) users get turned off by Github because the first thing they see is a bunch of code. I'm not saying that a large ...
Will anyone buy a premium plugin that's available at GitHub?
wordpress
For whatever reason I can't seem to get my .htaccess file to work correctly on a local Wordpress install. What I'm trying to achieve is to have the themes assets paths rewritten as such: <code> RewriteRule ^img/(.*)$ wp-content/themes/cashed/img/$1 [L] </code> The current location to my images folder is: <code> wp-cont...
Are you sure your default <code> &lt;Directory /&gt; </code> settings aren't getting overridden somewhere else? I have mine directly in the vhost and .htaccess and rewrite rules work fine. <code> &lt;VirtualHost *:80&gt; ServerName wp.project DocumentRoot "/Users/chris/Sites/wp.project" &lt;Directory "/Users/chris/Site...
MAMP.app & .htaccess - Can't override after config
wordpress
In order to refrain from possible duplicate URLs or conflicting URLs, I really want to use "postname" for a clean URL structure, EXCEPT for the blog ... for the blog and it's posts, I always want /blog/ to be apart of the URL. This makes total sense, and I don't quite understand why it doesn't function like this when y...
I've come to accept that this is just a limit of WordPress.
Permalink: postname EXCEPT for blog
wordpress
I am trying to display some widgets (Quora &amp; Goodreads) widgets inside Page or Post. How do I do that without displaying it inside Sidebar?
There's no easy way to do this. Many plugins that provide a widget also provide a shortcode (text in brackets that you can put in your post like this: [quora]). I have no idea whether either of your widgets also come with shortcodes. Though I've never used them, there are some plugins that claim to help you do this. (L...
How can I display widget in a Page or Post?
wordpress
I realize that maybe this isn't the best place to ask this, but since getshopped.org (the makers of the plugin) don't seem to have any support form, AND since I am unable to access the forums I'm posting here... After installing WP E-Commerce to test how it works, I discovered that all links to blog posts and pages on ...
Permalinks in settings were set for default. Changing them to /%category%/%postname%/ fixed my problem and now all posts and page permalinks go where they are suppose to.
All permalinks go to products page with WP E-Commerce plugin?
wordpress
<code> $s = $_POST['submitterms']; $querystr = " SELECT $wpdb-&gt;terms.* FROM $wpdb-&gt;terms WHERE lower($wpdb-&gt;terms.name) like '%$s%' "; $pageposts = $wpdb-&gt;get_results($querystr, OBJECT); echo '&lt;ul&gt;'; $x = 0; while ($pageposts[$x]) { $post = $pageposts[$x]; echo '&lt;li&gt;'; echo '&lt;a href="' . $pos...
You can do it easily. Your query should be: <code> $querystr = "SELECT `term_id` AS `id`, `name` AS `value`, `slug`, `term_group` FROM {$wpdb-&gt;terms} WHERE lower($wpdb-&gt;terms.name) like '%$s%'"; </code> See, here i've mentioned the name of the fields needed. For any other fields, you need to explicitly mention th...
Altering term_id and name via $wpdb class
wordpress
So following on from this post: stackexchange-url ("stackexchange-url I was wondering how exactly it would work integrating it into Wordpress. I have a custom post type setup, and so far I have tried both linking to a "ical.php" with the above link code (and changing the title into <code> the_title() </code> and the da...
I would use WordPress' feeds . You can create your own feed with <code> add_feed </code> . You specify a callback and this callback is responsible for displaying the output. Creating a feed <code> add_feed('my-events','wpse56187_ical_cb'); </code> <code> wpse56187_ical_cb </code> is that responsible for getting the eve...
Dynamic iCal generator outside/inside wordpress
wordpress
I have a VPS set-up and because it had limited RAM I set it up to run nginx instead of apache. But although performance has been reasonable, I've had problems with things like multi-site rules and plugins complaining. I was wondering if I used Apache and Nginx together, with nginx serving static files, apache php would...
If I use Apache &amp; ngnix together will I have fewer problems? Yes, of course. Please be sure to install and setup mod_rpaf in Apache, if you are going to setup Nginx as reverse proxy to Apache. I was wondering if I used Apache and Nginx together, with nginx serving static files, apache php would I get both performan...
If I use Apache & ngnix together will I have fewer problems?
wordpress
Hello at the moment I'm wondering how I would be able to make this work to post in Hierarchical order within the post loop. <code> &lt;?php foreach ((get_the_category()) as $childcat) { if (cat_is_ancestor_of('42', $childcat)) { echo '&lt;li&gt; &lt;a href="'.get_category_link($childcat-&gt;cat_ID).'"&gt;'; echo $child...
Use <code> wp_list_categories </code> instead, <code> &lt;?php $args = array( 'hierarchical' =&gt; true, 'child_of' =&gt; 42, //parent category 'hide_empty' =&gt; 1, //hide empty categories (set to 0 to show) ); wp_list_categories($args); ?&gt; </code> A full list of parameters for <code> wp_list_categories </code> can...
get_the_category listing in hierarchial order
wordpress
Am I declaring my custom post types incorrectly? My permalinks are only working intermittently on my site. I believe I have my server set up correctly; I have a few Drupal installs up along with my Wordpress install and their clean urls / htaccess rules are working fine. I've also tried disabling all plugins but that h...
Your rewrite slug is set to '/' - that's going to be a problem. It needs to be a valid string. By default it's going to be 'homepage', the name of the custom post type, but this is where you can change it to something else (e.g. 'homepages') if you're shooting for a specific URL structure.
Custom post types permalinks not working
wordpress
I'm developing a plugin (my first plugin), and I wonder how to think about [supporting and testing various plugin version and WordPress version combinations]. For example, if I develop a plugin, and release versions 1.0 and 1.1 and 2.0. Meanwhile, WordPress releases versions 3.2, 3.3 and 3.4. Now, at the one extreme: S...
Usually a plugin developed in WordPress version will run fine on several newer versions. What you need to care about is 'deprecated` features/apis in WordPress. Any API in WordPress is not removed overnight, rather it remains deprecated for several versions. You will get such a list here: http://codex.wordpress.org/Cat...
Plugin development: How many plugin and WordPress version combinations to support?
wordpress
How would I show posts that have a tag who's name matches the title of the current post? For example if you are on a post called "Hippo" at the bottom of the page I would like posts with the tag "Hippo" to be displayed.
The query would look something like this: <code> $title_tagged_posts_query = new WP_Query( array( 'tag' =&gt; strtolower( get_the_title() ) ) ); while ( $title_tagged_posts_query-&gt;have_posts() ) : $title_tagged_posts_query-&gt;the_post(); //Output whatever you want here. endwhile; </code> This assumes that the tag s...
Display posts with tag that matches current post title
wordpress
I have "publication_year" as meta_key for some images/attachments. I want to list all meta_values inside html table, but I don't want same publication_year value to repeat, my code is: <code> &lt;?php $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -1, 'orderby' =&gt; ...
One way would be to keep track of which years you've already printed. Using your code: <code> &lt;?php $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -1, 'orderby' =&gt; 'menu_order', 'order' =&gt; ASC ); $attachments = get_posts( $args ); echo '&lt;table id="bibliogr...
How to avoid duplicating same meta_value?
wordpress
Are there any plugin or code that sends out a email to me (admin) when a author or writer publish a post?
No need for plugin here are a few lines of code you can modify and paste in your themes functions.php file and you will get a new email whenever a post is published: <code> add_action('publish_post', 'send_admin_email'); function send_admin_email($post_id){ $to = 'admin@email.here'; $subject = 'mail subject here'; $mes...
Sends out email to admin
wordpress
I have a wordpress site that, for some users, they only see a blank page. In fact, they only get some sort of javascript (below). I've tried deactivating all plugins and changing the theme; I still get the same result. I don't have any compression plugins (like WP-Cache or WP-SuperCache) installed. What's the problem, ...
If you've disabled all plugins and switched back to the default Twenty Ten (or Twenty Eleven) theme and are still seeing this, then you've got a serious problem. First of all, the JavaScript is horribly obfuscated. Second of all, with no plugins and a default theme, you should see the default layout of WordPress. From ...
WP Site Only Shows Javascript for Main Page
wordpress
How can i filter the link given in "link to existing content". Eg: As in the above image. I just want WSP BANNER TO BE SHOWN. where WSP BANNER &amp; CALENDAR are custom POST types Any help will be appreciable.
Currently there are no ready filters available for this purpose. A ticket has been posted for the request.Lets hope we get one soon. Instead of hardcoding your custom post types its better to create a filter hook and use it Till then you can create your own filter. Open includes/class-wp-editor.php and make folowing ch...
Filter link to existing content suggestion
wordpress
I'm trying to make a post pagination like this: <code> button left image | 1 2 3 4 5 |button right image </code> but I can't get it work. I've tried: <code> &lt;?php wp_link_pages('before=&lt;p&gt;&amp;after=&lt;/p&gt;&amp;next_or_number=number&amp;pagelink= %'); ?&gt; </code> But how to add images to the left an right...
yes, it works now! Thanks I use this code to turn <code> ['next_or_number'] == 'next_and_number') </code> so I can mix it with numbers, arrows or graphics : <code> // Custom Next/Previous Page add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add'); /** * Add prev and next links to a numbered link list */ f...
wordpress post pagination with image buttons?
wordpress
I'm sure I'm missing something simple, as I rarely use shortcodes, but I can't seem to get the following shortcode to work. I want it to be an "enclosing" short tag vs. a "self-closing", but its being treated as the latter. <code> [bio_image name="my name" title="my title"] //image media in post content [/bio_image] </...
Remove the space after the shortcode name. <code> add_shortcode( 'bio_image ', 'bio_image_func' ); </code> becomes <code> add_shortcode( 'bio_image', 'bio_image_func' ); </code> I think WordPress is looking for a closing tag for <code> bio_image[space] </code> , which doesn't exist.
Enclosing Shortcode is acting like self-closing
wordpress
I want display different content in sidebar for every category, but as I create new ones I have to create the area for it. How can I have widget areas for every category and also display them on theme accordingly?
Not a good thing if you have a lot of categories, so be careful! First, add the following function in <code> functions.php </code> : <code> add_action( 'widgets_init', 'generate_widget_areas' ); function generate_widget_areas() { //Do not create for uncategorized category $terms = get_categories('exclude=1&amp;hide_emp...
How to generate and display widgets areas dynamically?
wordpress
For some reason the page nav doesn't work correctly. It's styled odd on the home page (http://noahsdad.com/), then if you go to a page (say page 2 for instance, http://noahsdad.com/page/2/ ) you'll see it really looks odd. I can't figure out what's happening. If anyone has any ideas I'd appreciate it. Thanks. Here is t...
You don't have a code issue, just CSS. In your default.css, just at the end, add this: <code> #menu-under-header .navbar-inner ul{clear:both !important; width:1000px;} .menu-header-container{clear:both !important;} #social-networking{clear:both !important;} </code> and that's it. You may want to add a position for soci...
Need help getting this page nav working correctly
wordpress
Situation is I have some posts which are showing in my home page there are some read more links(excerpts) after clicking on those links they go to the complete post page, now the issue is i want to open a pdf on one of the read more link, it is not working right now what i have done is I pasted the pdf url on the post ...
There are a number of ways this can be achieved, some more complex than others, some offering more functionality than others, however it all depends on your usage-case. For now, the most simple method is to use a combination of, custom fields and a... conditional if/else statement Step 1) In your post edit screen you n...
How to customize read more link
wordpress
DSoes anyone know how I can set a different valute in the select-options in contact form 7 plugin? Here is an HTML example of what I'm trying to do <code> &lt;selct&gt; &lt;option value="1"&gt;My car&lt;/option&gt; &lt;option value="2"&gt;Your car&lt;/option&gt; &lt;/select&gt; </code>
It looks like this is supported by Contact Form 7 natively, it's just not very obvious on how to make it happen. Here's a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/ Basically all you have to do is put the values like so: Visible Value|actual-form-value What...
Contact form 7 select box different value-text then content-text in option
wordpress
I'm new to WordPress and was wondering why in WordPress API do they tell you to use functions such as <code> prepare() </code> , <code> insert() </code> , <code> get_col() </code> , <code> get_row() </code> , <code> query() </code> , etc. when technically I can use the built-in PHP-SQL functions such as <code> mysqli_q...
There are a few different reasons. 1. Separation of Concerns Fundamentally, your logical code (i.e. your plugin or your theme) should not need to know anything about the database. At all. Really. The <code> $wpdb </code> object is the global database access layer, and you should be using it for all of your database acc...
Can i use php sql functions instead of $wpdb?
wordpress
I'm trying to create a portfolio page that will display a series of thumbnails and, when clicked on, will go to single.php. The code I'm using below seems to work in that when I click "see more" it goes to the proper page, however the thumbnails are not showing up. Any ideas as to why? Thanks. Live site. work.php <code...
In your work.php code sample you are calling <code> get_post_meta( $post-&gt;ID, 'the_post_thumbnail', true) </code> This has nothing to do with WordPress post thumbnails and is looking for a custom field with the post meta key 'the_post_thumbnail' For more info see: get_post_thumbnail_id wp_get_attatchment_image_src P...
trouble with the_post_thumbnail
wordpress
Hi I'm using XDEBUG to debug my WordPress code, is it possible to view the page building up in the browser while debugging? At the moment the page just hangs until the debugging process is finished then displays the fully rendered page. Ideally I'd like to see the page building up bit by bit as I debug through the them...
Just an Idea - I did not test this. Worth a try would be to play around with your PHP settings: <code> ; Implicit flush tells PHP to tell the output layer to flush itself ; automatically after every output block. This is equivalent to calling the PHP ; function flush() after each and every call to print() or echo() and...
Debugging WordPress themes with Xdebug, real time html output
wordpress
We have a custom post type called <code> listings </code> , and each <code> listing </code> has a custom field <code> zipcode </code> (which is a 5 digit number). We then have a custom taxonomy <code> area </code> , which can be "New York", "Los Angeles" etc. If the <code> zipcode </code> is "10001", "10002" or "10003"...
I'm sure this not best answer, however you may try like this <code> add_action('save_post', 'add_my_taxonomy'); function add_my_taxonomy($post_ID) { $area = array( 'ny' =&gt; 'New York', 'la' =&gt; 'Los Angeles' ); $zip = array( 'ny' =&gt; '10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10...
Automatically assign a custom post to a custom taxonomy based on custom field value
wordpress
I am trying to get start and end dates for posts filtered, and I found the documentation for the 'posts_where' filter, I am just testing it so far, but when ever I add the filter, it seems to pull in the loop data for the main navigation (i.e. from wp_nav_menu()) I added: <code> &lt;?php remove_filter('posts_where', 'u...
So first of all you'll want to make sure that you want to and your <code> WHERE </code> clause in. <code> posts_where </code> will fire for (almost) every query so you want to be sure that you're adding it to the right one. This can be done with the use of conditional tags . Note: The <code> WHERE 1=1 </code> is added ...
add_filter for where statment issue
wordpress
Been having a bit of a problem with my site regarding our caching method and my php code not refreshing or flushing. To start, my site is on a dedicated Nginx webserver. I used W3 Total Cache for the initial caching setup. Everything was set up to cache through Memcached. (I should note, my website is somewhat of a 'gu...
So any suggestions are welcomed. Suggestion #1 - Whenever Memcache is available in the server, I prefer Memcached Object Cache and Batcache , unless I have a specific reason to use W3 Total Cache. Whatever, W3 Total Cache offers, can be achieved without it too. For example, for minify, we have Better WP Minify , For Va...
PHP Code stuck in Cache [Memcached]
wordpress
I want to hide the content below when the user uses pagination to move from the initial page of the archive (page 1). Is there some way of detecting whether or not the current page is page 1? Content below needs to reappear if the user returns to page 1. <code> &lt;!--Hide Me if not on page one--&gt; &lt;div class="one...
There is an example on the wordpress codex. (link) . Basically you use an if statement on the variable <code> $paged </code> which stands keeps track of the current archive page.
Hide content after going to page 2 of archive, show content when back at first page
wordpress
Is there a function for getting a list of registered Meta Boxes and removing them? I see there is a method for adding, and removing. http://codex.wordpress.org/Function_Reference/remove_meta_box http://codex.wordpress.org/Function_Reference/add_meta_box
Not really, but you can define your own. All meta boxes are stored in the global variable <code> $wp_meta_boxes </code> which is a multi-dimensional array. <code> function get_meta_boxes( $screen = null, $context = 'advanced' ) { global $wp_meta_boxes; if ( empty( $screen ) ) $screen = get_current_screen(); elseif ( is...
Get List of Registered Meta Boxes and Removing Them
wordpress
I want display date based on how much time has passed since, i. e. Posted 12 minutes ago
This is quite simple: just replace the <code> get_the_date() </code> or <code> the_date() </code> with <code> echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; </code>
How to display date such "x ago"
wordpress
I am building a new WordPress theme and it is quite different from my current theme. Currently the dimensions of my images are much wider than how I would like them to be for my new theme I am developing. Is there way to scale down the widths programmatically and in mass? Is there a plugin that accomplishes this task?
if what you need is to apply this to big images (no thumbnails like in Gembel's solution) you can use CSS, including a max-width statement. For example: <code> .content img{width:98%; max-width:200px;} </code> of course you should adapt the numbers to what you need, but you'll get the idea
How can I scale down the width of images in bulk that are embedded in posts throughout the site?
wordpress
I'm outputting a list of pages in my custom post type — a kind of tree — using <code> wp_list_pages() </code> . All's going well, except now I want to put some classes in the li's for styling. Even that's not going too bad with the help of this guy: <code> function tsep_page_css_class( $css_class, $page, $depth, $args,...
Doesn't WordPress already at the class <code> current_page_parent </code> , <code> current_page_ancestor </code> and <code> current_page_item </code> (see source ). The filter you are using is called on 1046. As for your question, you create the array <code> $content_type </code> and then attempt to make a string out o...
Add classes + taxonomy terms to wp_list_pages() output
wordpress
Edit: Problem Solved, solution posted at bottom I'm going crazy trying to figure out why this is happening. This is well known issue, and I've done everything recommended so far. I'm using php version 5.3 and magic quotes are off. This issue only occurs when using the plugin wp_blocks, so I'm assuming there is somethin...
Solution The plugin used only a wordpress function called wp_kses_stripslashes, which only works on double quotes apparently. I simply further processed the passed data through stripslashes and voila.
Wordpress plugin WP-blocks is adding slashes before apostrophe
wordpress
We use the default WordPress <code> register_setting() </code> function to validate theme options. This call, for example: <code> register_setting( 'options-group', 'option1', 'intval' ); </code> Will validate whether or not <code> $option1 </code> is an integer. What can I use to pass an array of options to validate e...
What you need to do is build your own data validation function. Ozh wrote a great tutorial about this earlier, but here's the gist of it ... Assume your options array is called <code> $my_options </code> and it contains three fields, <code> 'text' </code> , <code> 'age' </code> , and <code> 'isauthorized' </code> . You...
Validate an option array
wordpress
I am trying to create a custom homepage where the site content is shown as follows... See image... http://i.stack.imgur.com/ykrdf.png With separate loops this is simple... 3 individual query_posts inside a category fetch loop... But I want to reduce the number of query posts from 3 to 1 per category since they are comi...
You can achieve this by checking where you are in the loop and outputting markup at the appropriate time. Within the object that holds the query results is a counter that keeps track of the current post, <code> $wp_query-&gt;current_post </code> . Note that it is zero-indexed, so first is 0, 2nd is 1, etc.. <code> &lt;...
Least Number of Loops to Create Custom Homepage?
wordpress
I want to query posts by their author role. And do something with the post based on the role. I know we can get the post by get_posts or WP_query, the problem is there are no argument to sort the post based on the author role. Or, we also can combine get_users and get_posts together, like this <code> $users = get_users...
I haven't really messed around with custom post queries before, but here is my try at a solution: <code> function get_posts_by_author_role($role) { global $wpdb; return $wpdb-&gt;get_results( "SELECT p.* FROM {$wpdb-&gt;posts} p, {$wpdb-&gt;usermeta} u" ." WHERE p.post_type = 'post'" ." AND p.post_status = 'publish'" ....
How to query post by user role?
wordpress
I wanted to display the site administrator/s not super administrator by blog id. Which outputs the site admin id and avatar. How to accomplish this?
In shortcode form: <code> /** * Shortcode for listing all admin users of a Multisite site * * Usage: [siteadmins blog="1"] */ add_shortcode('siteadmins', 'wpse_55991_site_admins'); function wpse_55991_site_admins($atts, $content = null) { $site_admins = ''; switch_to_blog( $atts['blog'] ); $users_query = new WP_User_Qu...
How to get the site administrator/s by blog id
wordpress
I have a <code> index,php </code> with various <code> new WP_Query </code> all working ok, but in this block I need to implement that "AJAX thing people love - the load more posts": <code> &lt;h2&gt;Latests articles &lt;?php bp_site_name(); ?&gt;&lt;/h2&gt; &lt;?php $destaque = get_term_by('slug', 'destaque', 'post_tag...
The tutorial that Michael Martin posted on Pro Blog Design should help you: http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/
Add AJAX "Load more" on custom query block
wordpress
Am using the custom menu widget to add a menu in the footer and i want to add a in the menu how can i do this ? like so... <code> &lt;li&gt;&lt;a href=""&gt;&lt;span&gt;menu1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; </code> if done it for the main nav using the link before below but as this is a widget am not sure where to ad...
Filter <code> 'walker_nav_menu_start_el' </code> and replace the link text. Prototype, not tested: <code> add_filter( 'walker_nav_menu_start_el', 'wpse_56028_title' ); function wpse_56028_title( $item ) { return preg_replace( '~(&lt;a[^&gt;]*&gt;)([^&lt;]*)&lt;/a&gt;~', '$1&lt;span&gt;$2&lt;/span&gt;&lt;/a&gt;', $item)...
add span to wp_nav_menu widget
wordpress
Existing code somewhere in a template or shortcode handler, display user profile biography: <code> &lt;?php if ( $user ) : $bio = get_the_author_meta( 'description', $user-&gt;ID ); ?&gt; &lt;div class="esineja_info"&gt; &lt;span class="bio"&gt;&lt;?php echo $bio; ?&gt;&lt;/span&gt; &lt;/div&gt; </code> How do I get th...
It turns out, my code above is indeed all that is needed. Apparently the mistake I made was that I didn't load the translated version of the page in the frontend at least once, so icl_t() didn't auto-register the strings. Also keep in mind, if you're looking at correct string count in String Translation context names, ...
WPML - how to translate user profile fields with icl_t()?
wordpress
i gave my editor role an access to my Widget settings. But i wonder why it is different when an admin access it. It has no drop down. see the attachment: http://i.stack.imgur.com/Rv3g3.png Thanks Ivan
You have accessibility mode enabled. To get the regular arrow drop down disable accessibility mode through the screen options menu.
WordPress Widgets no drop down
wordpress
I've created a new query for a custom post type of 'courses'. Those results are then to be filtered using tax_query, querying 3 custom taxonomies matching 1 or several term ID's. These are passed from a search page. Here's the code working find up to now: <code> // Lets emulate the posted ID's from the course search wi...
You can define the args outside of the <code> WP_Query </code> instantiation: <code> &lt;?php $tax_query = array('relation' =&gt; 'AND'); if (isset($search_course_area)) { $tax_query[] = array( 'taxonomy' =&gt; 'course-area', 'field' =&gt; 'id', 'terms' =&gt; $search_course_area ); } if (isset($search_course_level)) { ...
Conditional arguments for WP_Query and tax_query depending on if $somevar has a value
wordpress
I'm having issues ordering a loop of users by a custom meta_value. Reading the Codex for <code> get_users() </code> , it doesn't actually say that you can use the <code> meta_value </code> for orderby. When I try to do it I get a list of users not ordered by the meta_value. <code> &lt;ul&gt; &lt;?php $args = array( 'ro...
Try this code, but replace <code> METAKEY </code> to the key-name of your metadata. <code> &lt;?php function cmp( $a, $b ) { if( $a-&gt;METAKEY == $b-&gt;METAKEY ){ return 0 ; } return ($a-&gt;METAKEY &lt; $b-&gt;METAKEY ) ? -1 : 1; } ?&gt; &lt;ul&gt; &lt;?php $args = array( 'role' =&gt; 'author' , 'meta_key' =&gt; 'ME...
Override orderby to create list of users by custom meta_value
wordpress
How to run this filter only on some specific registered thumbnail sizes '$size' ? like 'large' , 'medium' .... <code> add_filter( 'wp_get_attachment_image_attributes', 'wpse8170_add_lazyload_to_attachment_image', 10, 2 ); function wpse8170_add_lazyload_to_attachment_image( $attr, $attachment ) { $attr['data-original'] ...
This is a hack, but I guess it should work... <code> add_filter( 'wp_get_attachment_image_attributes', 'wpse8170_add_lazyload_to_attachment_image', 10, 2 ); function wpse8170_add_lazyload_to_attachment_image( $attr, $attachment ) { //use your image size here with attachment if($attr['class'] == 'attachment-large'){ //d...
Add filter on certain thumbnail sizes only
wordpress
I'm trying to use cat_is_ancestor_of() for custom taxonomy categories but it's not working. Is there any other way to check if a category is child of another?
Use <code> term_is_ancestor_of() </code> . That is the function <code> cat_is_ancestor_of() </code> is calling: <code> term_is_ancestor_of( $parent, $child, 'taxonomy_name' ); </code>
cat_is_ancestor_of() for custom taxonomies
wordpress
I created the taxonomy 'machine types', and added several terms to it, like 'cranes' for example. The url to that term now looks like this: domain.com/machine-types/cranes How can I make this url query for only posts with the term cranes? And the same for all other terms, without creating a template for each term. I th...
You can create a <code> taxonomy.php </code> file and put your loop/query inside this file and as such anytime you are on a taxonomy page, no matter the term, be it cranes, bulldozers, etc the <code> taxonomy.php </code> will take over and handle the term in question (as shown in your URL). Taken from the WordPress Cod...
How can I query all post with currrent taxonomy term?
wordpress