question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
We've written a plugin that shows reviews upon usage of a shortcode. On some sites, Wordpress is adding <code> &lt;br&gt; </code> tags throughout the shortcode content, and others it does not. The shortcode works here (Nearby Now) . The shortcode has tags inserted here (Dent Biz). There's a couple of articles stackexch...
It turns out that the Infocus theme was the culprit. Deactivating it immediately solved the problem. Their support forum recommended using the [raw][/raw] shortcode surrounding our shortcode, which allowed us to use our plugin with the Infocus theme. [raw][recentreviews radius="15" count="3" zoomlevel="10"][/raw]
WordPress adding tags into plugin content
wordpress
I have a custom taxonomy X. I've specified that the UI should be shown (for debugging purposes), however the UI is now interfering with my automation. I have code that automatically mirrors terms into this taxonomy, duplicating it. Taxonomy X is effectively a copy of Taxonomy Y or a subset. This code is working almost ...
Like Bainternet suggested - <code> remove_meta_box( 'tagsdiv-custom_taxonomy_id', 'post', 'side' ); </code> to remove the default Metabox. If you want to still see the terms. Then re-register the metabox with your own custom callback. This callback function can then mimic the function used to display the default metabo...
Disable a Custom Taxonomies default save mechanism
wordpress
Maybe I simply do not understand what <code> get_template_part() </code> is doing … I have a file called <code> event-list.php </code> that should work as template for other pages and files so all my events (a custom post type) get listed! Inside this <code> event-list.php </code> I have this … <code> &lt;?php $loop = ...
Try globalizing <code> $post </code> inside of <code> event-item.php </code> . Also: be sure to call <code> wp_reset_postdata() </code> after you close your <code> $loop </code> while loop. e.g.: <code> &lt;!-- event-item.php --&gt; &lt;?php // globalize $post global $post; ?&gt; &lt;div id="event-&lt;?php the_ID(); ?&...
get_template_part() - post-meta not working?
wordpress
When using the_search_query to display search result on my site, the spaces between words are displayed with a + symbol. So if a visitor searches for "wordpress plugins" the_search_query output in search.php returns <code> wordpress+plugins </code> How can I remove the + symbol, and/or replace it with non-break space e...
Personally, when I do things like this I use <code> str_replace() </code> [ Link ] Using your above example it would be implemented like so: <code> &lt;?php $string = the_search_query(); $res = str_replace("+", " ", $string); echo $res; ?&gt; </code> That will replace any <code> + </code> with a space. Or if you want t...
Strip the + symbol from the_search_query
wordpress
I think this may be more of a general php question but I am posting it here as it relates to a WP function. I am having some issues with an <code> add_action </code> on <code> manage_posts_custom_column </code> inside a class. Here is the code (stripped a little): <code> class The_class{ function __construct() { $this-...
Your problem is a simple typo: <code> array($this, 'manage_post_columns', 10, 2) </code> VS. <code> array($this, 'manage_post_columns'), 10, 2 </code> I guess you see the difference
add_action 'manage_posts_custom_column' in a class
wordpress
I have a custom post type where I have a taxonomy <code> cities </code> and a term <code> berlin </code> . Archive can be seen at <code> example.com/cities/berlin </code> and it's rendered normally from the <code> archive.php </code> template. Now, I want to order them according to a custom field, <code> start_date </c...
You can't concatenate an array onto query_string like that. See Digging Into WordPress's post about looping for the right format. Alternately, you can use <code> array_merge() </code> like on the query_posts Codex page . Consider using <code> wp_reset_query() </code> after your loop. Sometimes you'll also see people sa...
Modify loop but keep the original query, what am I doing wrong?
wordpress
I tried to store an array containing about 50000 keys and respective values to the user meta using update_user_meta. Since, this was only a test, I ran a for loop to generate the array. <code> $test = array (); for ($i = 0; $i &lt;= 50000; $i++) { $test[$i] = $i; } update_user_meta($user_id, 'test', $test); </code> I e...
According to the DB schemea, the <code> meta_value </code> column is of type longtext, and that has a maximum size of 4GB, however you're unlikely to reach that. Eitherway storing large quantities of data in a single field is bad both from a practical point of view, a performance point of view, and data storage. I advi...
Is there a limit to the length/size of serialized data that can be stored as user meta?
wordpress
Say I built a site at test.example.com, and I now have it set up so that when you arrive at example.com you really see test.example.com, my problem is all the internal links created by wordpress want to go to test.example.com. Is it because Site Address (URL) under settings is still test.example.com? Any way/best way t...
The internal links are all hard-coded; you'll have to do a search/replace in the database to fix them. This is a good script for search/replace that will go through your posts, widgets, everything: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ Download the script, and upload it into your Wor...
URL Forwarding - wordpress links reverting back
wordpress
Currently the RSS feed of my WordPress blog gives me the latest published posts. Is it possible to change this so that it returns the ones that are latest updated instead? So that the latest published are still in the feed, but if I update an old post it would pop up in a feed reader.
Try this (not tested) add to your functions.php of active Theme <code> function wpse49312_alter_the_query( $request ) { $dummy_query = new WP_Query(); $dummy_query-&gt;parse_query( $request ); if ( $dummy_query-&gt;is_feed() ) $request['orderby'] = 'modified'; return $request; } add_filter( 'request', 'wpse49312_alter_...
Possible to get feed to return latest updated posts rather than latest published?
wordpress
My website is a multi author blog. I would like to give special promotion for the first 100 published posts in my blog? What is the proper way to implement it? I mean should i add some meta value for first 100 published posts and then query it later using that meta value? If yes can anyone tell me how? Thanks
Here is what I would do: Run an SQL query like so: <code> SELECT * FROM `wp_posts` WHERE `post_status` = 'publish' AND `post_type` = 'post' GROUP BY `post_author` ORDER BY `post_date` ASC LIMIT 100 </code> The above will give you the first 100 authors to have a post published. or: <code> SELECT * FROM `wp_posts` WHERE ...
I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
wordpress
I created CPT topic <code> function wpse100_create_cpt() { register_post_type( 'topic', array( 'labels' =&gt; array( //..... ), 'public' =&gt; true, 'publicly_queryable' =&gt; true, 'capability_type' =&gt; 'post', 'hierarchical' =&gt; false, 'rewrite' =&gt; array( 'slug' =&gt; '/topic', 'with_front' =&gt; false ), 'has...
I found solution. Big Thanks @Scribu stackexchange-url ("Alternative to query_posts for main loop?") Now works fine and no more 404 error. <code> function wpse49295_alter_the_query( $request ) { $dummy_query = new WP_Query(); $dummy_query-&gt;parse_query( $request ); if ( $dummy_query-&gt;is_single() ) $request['post_t...
Custom Post Type and single-posttype template
wordpress
I'm having some trouble adding jquery-week-calendar to WordPress' admin interface using <code> add_menu_page </code> and other API methods. What I found out is that the default <code> jquery-ui </code> and other JavaScript references are interfering in the rendered calendar behavior. How can I remove these extra script...
According to the <code> load-scripts.php </code> file, scripts that are not enqueued will not be loaded, so I don't need to worry about it when using hooks like <code> admin_enqueue_scripts </code> and the <code> wp_deregister_script </code> function. <code> foreach( $load as $handle ) { if ( !array_key_exists($handle,...
Removing admin javascript
wordpress
I've created a custom post type "projects" that has a meta box for additional information (client name, type of project, budget, etc). I'd like to be able to display this information on the front-end. The custom post type is available to be added to custom menus if desired ('show_in_nav_menus' => true), but when you vi...
Solution: Inside a function, retrieve meta box field values using get_post_custom_values() and added it to $content passed to the function. Use 'the_content' in the add_filter.
Custom Post Type & Meta Box - Displaying meta box information on front end?
wordpress
Currently, when you click a member's picture of name in BuddyPress, you are redirected to the member's Activity Page. How can I get Buddypress to default to the member's Profile tab instead?
Drop the following into your wp-config.php file, above the "That's all, stop editing" line: <code> define( 'BP_DEFAULT_COMPONENT', 'profile' ); </code>
How to you redirect to Member Profile in BuddyPress
wordpress
I want to set up a private WordPress site, with only 2 users, all I need is a simple private site functionality, with visitors unable to see anything when trying to login, only being redirected to the login page. RSS should also be blocked. I have found one plugin which does this, but it doesn't seem to be maintained, ...
Use this : http://wordpress.org/extend/plugins/password-protected/ A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress privacy settings. How can I change the WordPress logo to a different image? Install and configure the Login Logo plugin b...
Restrict WordPress to Private
wordpress
Since the post_id is unique and no full text search is needed. So is the structure %postname%/%post_id% really improve performance?
I hate to answer this with a link, But with WordPress 3.3, how it searches for permalinks have been greatly improved so you can almost put anything into the permalinks and it will be fast. http://ottopress.com/2011/how-the-postname-permalinks-in-wordpress-3-3-work/
Can Permalink structure of %postname%/%post_id% improve performance
wordpress
I'd like to test some theme changes on my live site, but I obviously don't want regular users seeing any errors that may arise from it. I'd like to just duplicate my theme folder and if I'm logged in as admin, then that theme is shown to me, otherwise, the old theme is shown to my users. Is there a plugin to do this?
I just wrote this quick plugin and it seems to work. Let me know if there is a better way. <code> &lt;? /* Plugin Name: Theme Switch if Admin Description: Display different theme to user if logged in as admin Author: Kyle Barber */ add_filter('template', 'change_theme'); add_filter('option_template', 'change_theme'); a...
Show different theme for admin?
wordpress
I have 3 theme files: <code> header.php </code> , <code> navigation.php </code> and <code> page.php </code> <code> page.php </code> calls <code> header.php </code> They both have content which is added to via a <code> custom box </code> . <code> navigation.php </code> has some content added to it via a <code> custom bo...
You can include any template you want using <code> get_template_part() </code> e.g.: <code> &lt;?php get_template_part('navigation'); ?&gt; </code> Using this function also gives you child/parent theme support. Also of note, you could put: <code> &lt;?php get_template_part('navigation','search'); ?&gt; </code> Which wo...
How do I include a template file while allowing it to render its own dynamic content added via custom box?
wordpress
I'm using W3 Total Cache and Nginx with Varnish, and I'm very happy with the speed. However, I noticed that when I schedule a post, the post doesn't get automatically posted when I'm a visitor . When I'm logged in as an admin and I reload the page it correctly posts the new content. Varnish config (default.vcl) <code> ...
wp_schedule_event is only run when your site is visited and the scheduled time has past. If varnish is serving a non expired cached page then your visitor is not hitting WordPress. Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger whe...
Scheduling doesn't work due to caching?
wordpress
I'm trying to rewrite my url for a custom_post_type named <code> wr_events </code> with one of its custom_taxonomy terms from <code> event_type </code> <code> add_action('init', 'wr_events'); function wr_events() { register_taxonomy( 'event_type', 'wr_event', array( 'label' =&gt; 'Types', 'singular_label' =&gt; 'Typ', ...
Change all your %event% to %event_type%. I hope that works for you.
Rewriting a custom-post-type permalink with taxonomy term?
wordpress
Background: I've only done vanilla theme and direct installs until now. The site I'm working on has an existing (ancient) Mambo install in root directory. For the new Wordpress revision, client wanted to develop the content of new site before replacing it. After reading the Codex, I decided doing a subdirectory install...
If I understand you correctly, you're removing the old Mambo site and intend to run WordPress as the main site in this domain. If that's the case then (depending on any plugins that you have running) all you will need to do after making backups of everything is move the entire contents of your /wordpress directory up t...
Moving from subdirectory and subdomain -> root
wordpress
If I were to load a custom library into wordpress, what would be the best place to add it? Since there are a bunch of global vars defined at the top of the library, I would not want that to be done thru a hook where I'm forced to use a wrapper function whereby my library globals will be treated as local to that functio...
You might want to look into creating a MU (Must Use) plugin, see Wordpress Codex . Within this file, you can include your library (using <code> require </code> ) or you could just tweak your library file a bit and use it directly as the MU plugin. The <code> session_start() </code> and <code> ob_start() </code> functio...
integrating external php library into wordpress- the right way
wordpress
I have a group of themes that a client needs consolidated into one. Everything is fairly straight forward, except each theme has theme-specific page templates. Instead of pooling all the template files together in the new master theme, how can I reduce them down to one dynamic template that displays differently dependi...
Personally, I build everything within index.php of each template. I then do conditional checks. Example: <code> if(is_front_page()){ // Home page layout } elseif(is_page()){ // General page layout if(is_page('contact')){ // Page layout specific to the contact page } elseif(is_page('about')){ // Page layout specific to ...
How to consolidate multiple static page templates into one dynamic one?
wordpress
I'm looking into moving my WordPress blog from an old domain to another domain that I own. The old domain is getting expensive at $25/year and I have to renew in a month. I had the old domain for 15 years but it no longer serves it's purpose as a standalone blog. I have several options for handling this: Leave it as is...
I found my answer on Google's Moving Your Site page. To prevent confusion, it's best to retain control of your old site domain for at least 180 days. http://support.google.com/webmasters/bin/answer.py?hl=en&amp;answer=83105 Due to circumstances beyond my control, my WordPress installation broke down. I did a fresh inst...
How long to keep old domain for 301 redirects after moving WordPress?
wordpress
Is it possible to remove the <code> Visual </code> \ <code> HTML </code> tabs from <code> wp_editor </code> and display only the TinyMCE editor? Basically, right now, I'm using <code> wp_editor </code> to display the smallest possible TinyMCE editor I can - only one button is needed, italics. What I'd like to do is mak...
Just set 'quicktags' parameter of the settings array to false. <code> wp_editor('', 'some-id', array('quicktags' =&gt; false) ); </code>
Remove HTML editor and visual/HTML tabs from TinyMCE
wordpress
i want to create my own function in wp-admin same like do in wp-content-> functions.php, but i don't know where is the function file in wp-admin folder. anybody know where is the function file in wp-admin folder?
There is no function file in "wp-admin" folder, you do not need to edit that folder. Wordpress has Plugin api to do that, http://codex.wordpress.org/Plugin_API/ Create a plugin and write function in your plugin file.
Where do i create my own function in wp-admin
wordpress
I'm working for a WordPress Plugin. The plugins is for library management, for my university. I created custom post types with taxonomies for keeping books information stored. Now I want to create another post type which will keep records for books and and users. For instance, I'll create new post type called "Issue". ...
To get the users who have the role called student, use the <code> WP_User_Query </code> object For storing the fields, use post meta just as you would on normal posts, remember to declare that your custom post type supports custom fields when being registered For your dropdown/etc you will need to register metaboxes Mo...
Need idea: custom post type and custom meta
wordpress
I have tried everything to override the BP Avatar. Found about 5-6 different Google results that basically all point to the same solution: <code> function override_bp_member_avatar($url) { return get_stylesheet_directory_uri() . '/default_avatar.png'; } add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); // ht...
The filters you cite are only for the default/fallback avatars. If you want to replace BP avatars altogether, the key filters are <code> bp_core_fetch_avatar </code> and <code> bp_core_fetch_avatar_url </code> . The latter filters the entire HTML avatar element, while the latter does just the URL. How you do the filter...
How to override Member's Avatars in BuddyPress
wordpress
I have a custom post type called 'episode'. Attached to 'episode' I have a custom taxonomy called 'video_type' that contains two terms: "bonus-footage" and "episode"; "episode" contains two child terms "season-1" and "season-2" (other seasons will be added in the future). I want to grab only the most recent post of the...
The <code> tax_query </code> parameter is an array of arrays , not just an array. This: <code> 'tax_query' =&gt; array( 'taxonomy' =&gt; 'video_type', 'terms' =&gt; 'episode', 'field' =&gt; 'slug', 'include_children' =&gt; true, 'operator' =&gt; 'IN' ), </code> Should instead be this: <code> 'tax_query' =&gt; array( ar...
"tax_query" parameter not working with WP_Query
wordpress
My php_error.log in my console (locally on OSX) is reporting 3 PHP Notices. The PHP Notices only appear when browsing each admin page in the back-end for a site (running multisite) that uses a child theme. The child theme uses the parent theme's sidebar.php which the code below is placed in. The PHP notices do not show...
That's pretty simple: You're trying to get the <code> parent </code> property from the <code> $post </code> object, but that is either <code> NULL </code> or simply not attached. In both cases, you are <code> Trying to get property of non-object </code> from the <code> $post </code> object. Simply check <code> if ( iss...
PHP Notices appear when browsing any page in admin, but only for child theme, using code from WP Codex
wordpress
First off, I want to say thank you for taking the time to even read this, I really do appreciate the help this site and it's community has given me thus far. i have looked forever to be able to find a way to append (display inside an added div) some image meta data just below EVERY image in EVERY single post. I have fo...
UPDATE I did not test this method, but it is not very old. It adds custom meta information to the caption section of the image, which can then be styled as needed. Again, I did not try the method, and I am not a coder, but from reading through the tutorial, it sounds like it fits your needs. Add Custom Meta Fields to M...
How to Display Image Meta underneath EVERY image in EVERY post
wordpress
Been using this answer --> > (stackexchange-url ("link")) to create some custom fields in my categories and it works great ! my only problem is that i have a frontend form that allows creating new categories with an unrelated form and i would like to insert values for my custom fields as well as each category pre-defin...
the function <code> wp_insert_term </code> returns the newly created term id (or WP_Error on error), so once your create your term you need to store it's ID and then you can save the "extra fields" using <code> get_option </code> , <code> update_option </code> something like: <code> if($_SERVER['REQUEST_METHOD'] == "PO...
Update custom category fields front-end
wordpress
First post on this site. Hope to get some help from you guys. Probably a simple answer for you experts. I have two category's (news &amp; work). I want to show on my index page (wordpress startpage/blog) the five latest news at the top (cat. news). Below that i want to show my post (cat news &amp; work). I also have st...
Where you do your pagination, you can use something like <code> if( $page != 1 ) </code> . This allows you you to output certain sections on only the first page. You will need to change <code> $page </code> to your pagination variable, but that is trivial.
Multiple loops on index page with sticky post and pagination
wordpress
I know there are plenty of question and posts about this out there, however I couldn't find a solution or existing thread to my specific question. If I list my categories and click on "cars" the url looks like this <code> url/category/cars </code> Is it simply possible to use some function in functions.php to change th...
If you go to Settings-> Permalinks and change <code> Category Base </code> to topics, you won't even have to write any code to make the change, as wordpress includes this functionality by default.
Rewrite /category/cars into /topics/cars
wordpress
This WordPress Codex document clearly shows how to get the name of the first tag of a post: <code> &lt;?php $posttags = get_the_tags(); $count=0; if ($posttags) { foreach($posttags as $tag) { $count++; if (1 == $count) { echo $tag-&gt;name . ' '; } } } ?&gt; </code> How do I modify the aforementioned code, so that a hy...
Instead of <code> echo $tag-&gt;name . ' '; </code> use <code> echo get_tag_link( $tag-&gt;term_id ); </code> See the Codex on <code> get_tag_link() </code> and <code> term_id </code> . And encapsulate the code in a function. Put this into your <code> functions.php </code> : <code> function wpse_49056_first_post_tag_li...
How to get the first tag of a post as a hyperlink?
wordpress
What I want to do is output a custom field content (which is a button with a dynamic link that's being inserted in the value of the custom field of each posts) right after the_content and before the plugins. This is the code for the custom field: <code> &lt;div class="button"&gt; &lt;a href="&lt;?php echo get_post_meta...
This is the answer - code to be added in the functions.php: <code> add_filter( 'the_content', 'my_the_content_filter', 0 ); function my_the_content_filter( $content ) { if ( is_single() ) { global $post; $pgLnk=get_post_meta($post-&gt;ID, 'Button', true); $content .= '&lt;div id="button-link"&gt;&lt;a href="'.$pgLnk.'"...
custom field output after the_content
wordpress
So I've Googled and followed countless tutorials, read documentation on MySQL, Visual Studio, WordPress, and Plesk. I try to leave posting on this site as the final option and it seems it has come to that. As simply put as possible, I want to display the list of categories from my WordPress blog on another ASP.NET/C# w...
There isn't an RSS of the names of the categories specifically otherwise I would have used the XML from the RSS feed with XSLT to display the category list that way. There is a handy function named <code> add_feed() </code> . You can create any feed or other output with it. Should be useful in your case. And it is pret...
Accessing WordPress MySQL Database via Data Connection in Visual Studio 2010 using C#
wordpress
I want to display specific posts from an array with specific tags i.e. "Bolivia" and "Brazil" and then show the post thumbnail and permalink. This is the code I am using so far but as you can see I am not calling the tags. Thanks. <code> &lt;?php query_posts(array('category__in' =&gt; array(4), 'posts_per_page' =&gt; 4...
See the WP docs for query_posts . Relevant excerpt: <code> The following returns all posts that belong to category 1 and are tagged "apples" query_posts( 'cat=1&amp;tag=apples' ); You can search for several tags using + query_posts( 'cat=1&amp;tag=apples+apples' ); </code> Or using the array version you're using, somet...
Display posts and thumbnails with certain tags
wordpress
I have some text fields in a custom post type that I fill in at first, but need to delete on a future update of the post. When I delete the text in the field and save the post, the text I deleted comes back! If I enter a space, it saves OK. Does anybody know how I can fix this? Here are the parts of the code for my cus...
The problematic line is this one: <code> if (isset($_POST["book_title"]) &amp;&amp; $_POST["book_title"] &lt;&gt; '') update_post_meta($post-&gt;ID, "book_title", $_POST["book_title"]); </code> That logic says: If the submitted form contains a field called 'book_title' and if the content of the 'book_title' field does ...
Custom Post Type Meta Box Text Input Field Won't Save When Blank
wordpress
I noticed that when I'm working on a php page that loads wp programmatically, some of my errors are not fired. For example, a variables that has not initialized previously creates a warning when I have the E_ALL on top, but not when I load wp after that. Any comments? how do I put wordpress in a mode so that anything w...
if you set <code> WP_DEBUG </code> to <code> true </code> in <code> wp-config.php </code> it should output all your errors. Alternatively, you can use something like Debug Bar or BlackBox to display the errors. How much you need should determine your solution.
debugging wordpress
wordpress
Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head? I can see the benefit on large sites, where you may move around directories or have multiple people mucking around in the fi...
Are you using a Theme that you control? If not, then every time the Theme updates, you'll lose your modifications to the header. Or else, you'll have to fork the Theme, or maintain/backport your changes every time the Theme updates. Do you only use Plugins under your control? If not, then you'll have to check for scrip...
What are the benefits of using wp_enqueue_script?
wordpress
I'm writing a plugin that realies on custom post types, new taxonomy and few custom fields. All this data will be private (not queryable or searchable). I'd like to provide an admin page to the user, to add and edit this data in a more suer-friendly way. For instance, the custom post type will have only a title and the...
You will need to start reading about the setting and options API, and then pull your CPT and Taxonomies into it. Have a start here: http://codex.wordpress.org/Creating_Options_Pages http://codex.wordpress.org/Settings_API http://codex.wordpress.org/Class_Reference/WP_List_Table http://net.tutsplus.com/tutorials/wordpre...
Create a custom admin page for custom post type + taxonomies + metas
wordpress
I need a 3 part conditional statement with all negatives but I can't get it to work. I need to say that the post isnt in category 'videos' or its child categories and isn't from the author with the id of 3. This is what I had but obviously doesn't do the trick. <code> if (!in_category('videos') || !post_is_in_descendan...
I like to split this kind of thing to more than one conditional, as it makes it easier for me to read. <code> if( !( in_category( 'videos' ) || post_is_in_descendant_category( 9 ) ) ) { if( get_the_author_meta( 'ID' ) != 3 ) { } } </code> Given, it's a bit more code, but that's the way it reads best to my eyes.
Combining multiple conditional statements
wordpress
I'm writing a new theme from scratch, based off the Toolbox theme. My installation of WP is straight out of the box. I added add_theme_support('custom-header'); to my functions.php file, but the "header" options screen does not appear in the dashboard. I can see it if I visit the site, in the toolbar at the top, but no...
I was told that <code> add_theme_support('custom-header'); </code> is not supposed to work as I expected yet. See the full answer I received stackexchange-url ("here").
add_theme_support( 'custom-header' ) does not add option menu in dashboard
wordpress
I have a custom meta box with a dropdown displaying all the WP users via wp_dropdown_users. It saves which WP user is chosen with the post, so that all works. However, is there a way to make it show the selected user in the dropdown when going back to edit, rather than the first in the list? I've used the selected() fu...
You need to set <code> selected </code> argument for the <code> wp_dropdown_users </code> function. Do it like this: <code> wp_dropdown_users( array( // ... 'selected' =&gt; $user_id, // ... ) ); </code> Read documentation for wp_dropdown_users function
Using wp_dropdown_users and selected() function?
wordpress
I have my blog page limited to 5 posts on the main page, which I'm happy with. However, I want my tag pages to list much more, maybe 15 or so. How do I most easily make this change? There's no option on the reading page. thx!
I would put this in functions.php: <code> function main_query_mods( $query ) { // check http://codex.wordpress.org/Conditional_Tags to play with other queries if(!$query-&gt;is_main_query()) { return; } if(is_tag()) { $query-&gt;set('posts_per_page',15); } } add_action( 'pre_get_posts', 'main_query_mods' ); </code>
how to change # of tag posts on /tag page?
wordpress
I've seen a lot of code on how to add a <code> first </code> and <code> last </code> class to a WordPress menu, but in my instance I would like to add a <code> last </code> class to the last li in the sub-menu that WP generates. Here's what I would like to achieve in it's simplest form. <code> &lt;ul&gt; &lt;li&gt;Menu...
Put the following in your <code> functions.php </code> <code> class SH_Last_Walker extends Walker_Nav_Menu{ function display_element( $element, &amp;$children_elements, $max_depth, $depth=0, $args, &amp;$output ) { $id_field = $this-&gt;db_fields['id']; //If the current element has children, add class 'sub-menu' if( is...
Add a .last class to the last in each ul.sub-menu
wordpress
[this is not a Multisite question] Update: this question is a logical impossibility, or a mind loop if you will, check update bellow. The technique is laid out here in WPEngineer . It allows having a single plugins folder to serve many WordPress sites running in the same server. So, all my development sites have this i...
I guess what you are saying is that it then 'exports' the wrong system's xml (I'm not familiar with the plugin) ? Ideally the plugin itself should be including/using the code rather in such a way so that it still knows the context/system in which it is being used irrespective of where the code is stored. Have you tried...
Many Single Sites, One Plugin directory - adjust plugins_url()
wordpress
I'm using code like this <code> $post = get_blog_post( $blog_id, $data ); echo __('Post on') . ' "&lt;a href="'.$post-&gt;guid.'"&gt;' . $post-&gt;post_title . '&lt;/a&gt;"'; </code> But the href link looks like this <code> mysubdomain.example.com/?p=345 </code> instead of permalink. Can anyone tell me how to get perma...
Ok i found the answer. <code> $post = get_blog_post( $blog_id, $data ); $link = get_blog_permalink( $blog_id, $data ); echo __('Post on') . ' "&lt;a href="'.$link.'"&gt;' . $post-&gt;post_title . '&lt;/a&gt;"'; </code> I hope it will be useful for others :)
How to get permalink using get_blog_post function in a multisite?
wordpress
I’ve hit another small rock in my current project! I’m trying to list (and link) to the archive page for the top 4 most used terms for a custom post type. I have this; <code> get_terms('trade',array('orderby'=&gt;'count','order'=&gt;'DESC','number'=&gt;4)) </code> ..which is along the right lines but I can’t seem to fi...
I if were you, I'd have two options in my mind. Both hinge on the fact thsi is an inherently expensive computation and no mysql trickery will reduce the load with the data you have. So Option 1, do it the expensive way and store the data for a rainy day You're going to have to swallow the cost of calculating this, but ...
Get the most popular terms for a custom post type
wordpress
I have a multi-author website and I use the WyPiekacz plugin to require that authors add 1-5 tags, select only a single category, and include a featured image (stackexchange-url ("and require minimum dimensions for the featured image")). WyPiekacz also can restrict title/content min/max length. WyPiekacz is great, but ...
You should never edit the core files of WordPress. Instead you should only ever edit Plugin files and or Theme files (Plugins or Themes folder) One of the easiest was to achieve this would be via jQuery; <code> jQuery('&lt;div/&gt;', { id: 'your-note', text: 'Add up to 5 tags...etc' }).appendTo('#tagsdiv-post_tag .inne...
How to Add Reminders/Notes to New Post Meta Boxes
wordpress
I need a function that when a post is saved/updated, it will scan the post for the first image. This image has already been uploaded to the media gallery but it has not been attached to the post. So, after the function finds this image, it has to attach it to the post, and after it is attached, it has to set it as feat...
great, yeah i did some research. I posted here as last resort. However, last night I found this plugin http://www.bbqiguana.com/wordpress-plugins/add-linked-images-to-gallery/ it does quite what I want, but it is getting only external images. How can I adapt it so it also gets internal images?? here is the code: <code>...
Function to scan for image, attach it to post, set it as featured
wordpress
I've developed a plugin and now I want to make it RTL compatible. Does anybody know how to determine is RTL enabled in admin panel or not? Or maybe somebody knows any CSS tips for RTL support?
I think you're looking for the function <code> is_rtl() </code> . Have a look in de codex: http://codex.wordpress.org/Function_Reference/is_rtl
modify plugin to support RTL
wordpress
I’m using a specific template on my self-hosted WordPress blog to display a page with randomized posts. Recently, I configured W3 Total Cache to make use of a content delivery network (CDN). When not logged in as the administrator, a user will have some elements of the site served through the CDN instead of fetching a ...
Got the solution. Instead of using the CDN exclusion list, I use the plugin (W3 Total Cache) “Page Cache” option. Once logged in as the administrator, go to W3 Total Cache settings (a tab called “Performance”). Navigate to “Page Cache” and then to the field named “Never cache the following pages:” Finally enter the nam...
How to exclude a specific template from being cached by a CDN
wordpress
I am using the Advanced Custom Fields plugin , which is very good. I am trying to take the output of one of the fields I created and give it the "permalink treatment", that is strip out non-alphanumeric characters like slashes, convert uppercase to lowercase, and convert spaces to dashes. Specifically I am wanting to d...
You could use <code> sanitize_html_class() </code> or <code> sanitize_title_with_dashes() </code> . Both functions do almost the same. But note that much more characters a valid in CSS class names. Examples: ✂ ✉ ✔✽ ✾ ✿ ❀ ❉ ❤ ❦ ☂ ☔ ☎ ☘ ♫ ♻ ⚥ Update I recommend to encapsulate the code in a prefixed function to avoid coll...
How to strip non-alphanumeric characters, convert spaces to dashes, uppercase to lowercase in this context
wordpress
How to give the source location path in the jquery code, where my file is in cah-new/wp-content/themes/theme_name/includes/func.php and i have to give that path in the jquery code <code> $.get(\"func.php\", { </code> kindly help me, thanks in advance
<code> $.get('&lt;?php echo get_bloginfo('template_url')?&gt;/includes/func.php', { </code>
How to declare/provide file path in JQuery which is emeeded in the Wordpress theme
wordpress
Is it possible to have multiple domains (each with unique child theme) on one installation? I'm aware of Wordpress's new feature called "Network", which allows you to have one installation for multiple sites. Ideally each site will have it's own child theme, or something similar.
Use the plugin WordPress MU Domain Mapping . Read the installation instructions very carefully. There is also an ebook WordPress Multisite 101 where you can read more (like migration from single site installation etc.). You can activate themes per single site as usual. Or set the constant <code> WP_DEFAULT_THEME </code...
Multiple domains with different child themes on one installation?
wordpress
I'm using Contact Form 7 and can display the form by putting the following in the content text field <code> [contact-form-7 id="453" title="Contact form 1"] </code> . Now I need to display the form outside the loop. How can I execute a short code from within my template code? Update I found some suggestions to execute ...
do_shortcode should do the trick. I don't think you need the 'echo' before it though, I have never done so myself and never had any problems.
How can I execute shortcode outside the loop?
wordpress
I know you can use the wordpress methods for getting a featured image, however with this particular project I need to get the featured image via mysql query. Can anyone point me in the right direction. Thank you. This is what I have so far but my query is not doing the trick. I have the $post-> id stored as a variable ...
<code> $Featured_image = $wpdb-&gt;get_results(" SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = '_thumbnail_id' ORDER BY p.post_date DESC LIMIT 15 ",'ARRAY_A'); </code>
Get Featured Image via direct sql query
wordpress
I recently installed the google+ and facebook widget plugins to my pages and I do not like it's current position. I'm not sure where to begin looking.. Thanks.
It depends on the plugin, but you could edit your post template and either use a template tag (if one exists), a shortcode (if one exists), or call the widget directly . Either way, you'll have to edit the template (unless you want to register a new sidebar).
How to place my g+ or fb plugin at the bottom of post or page?
wordpress
I am trying to use the <code> $post </code> object from functions.php in my theme however if I attempt to <code> var_dump($post) </code> it returns <code> NULL </code> . Here is my code: <code> function breadcrumb_navigation() { var_dump($post); $page = $post; $parents = array(); while ($page-&gt;post_parent){ array_pu...
Call in <code> global $post; </code> at the top of the function.
$post object is null
wordpress
Is there a way to replace the default checkboxes by radio buttons in the custom post type taxonomy UI? I have custom post type 'questions' with taxonomy 'answer type' (single selection [radio button], multiple selection [checkboxes] and pattern matching [dropdown boxes). I need to make sure the users can only pick one ...
When you register a taxonomy WordPress automatically handles producing the appropriate metabox. First you need to 'de-register' this default metabox: <code> add_action( 'admin_menu', 'myprefix_remove_meta_box'); function myprefix_remove_meta_box(){ remove_meta_box('my-tax-metabox-id', 'post', 'normal'); } </code> Where...
custom post type taxonomies UI radiobuttons not checkboxes
wordpress
I'm developing a plugin and I try to use a class (following the method of another plugin). But I don't understand why my constants are not globally available. This is my code: <code> /* Plugin Name: Some simple plugin */ if (!session_id()) session_start(); class myPluginClass { function __construct() { /* Set the const...
Your constant is defined in the "plugins_loaded" action, but you are trying to access it before that action gets to be executed.
Why are my constants not available outside my class?
wordpress
How can I hide the img-tag if there is no attacment? (function is from this tutorial: http://wp.tutsplus.com/tutorials/automagic-post-thumbnails-image-management/ ) <code> &lt;img src="&lt;?php get_attachment_picture();?&gt;" /&gt; </code> I need something like this: <code> &lt;?php if ( get_attachment_picture()) { ?&g...
Assuming you're following this tutorial: http://wp.tutsplus.com/tutorials/automagic-post-thumbnails-image-management/ Replace the echo statement at the end of get_attachment_picture with a return, then change your image code. Here is your new image code: <code> // get the URL of the image $src = get_attachment_picture(...
How to hide image-url if no attachment?
wordpress
I built a mobile version of a wordpress site and added some PHP code in the wordpress index.php file to detect mobile users and HTTP-redirects them to m.website.com ( which is not a wordpress installation. This PHP standalone mobile site scrapes the wp site for posts and displays them ). All works well, and every reque...
I'd use responsive design rather than a mobile subdomain copy of the site, however if you really do want this, then put this code in a plugin: <code> // this function doesn't exist prior to wordpress v3.4 if(!function_exists('wp_is_mobile')){ /** * Test if the current browser runs on a mobile device (smart phone, table...
Get permalink for a post from inside Wordpress and route to a related site
wordpress
I am coding an exam plugin with following flow: Subject Categories (custom taxonomy) Exams (custom post type) related to subject categories (custom taxonomy) MCQ's (custom post type) related to exam (custom post type) On Adding New MCQ I need to relate it with exams but exams is a post type not taxonomy. How can it be ...
Your data organisation is not perfect, which is why you're faced with the current predicament. Instead of 2 post types and a taxonomy, use 2 taxonomies and 2 post types Subject Categories ( taxonomy ) Question Sets ( taxonomy ) Exam ( post type ) MCQ's ( post type ) Assign MCQ's to a question set, and assign exams to b...
How to relate one custom post type to another custom post type
wordpress
So long story short, someone told me about BACKUPBUDDY and how good it is, etc, and it is...now long story short, one of my clients, wants to move their site from FATCOW to HOSTGATOR. I went in, created the backup with BACKUPBUDDY on the old site(fat cow), then went to the new site and migrated the info.(into hostgator...
The database still has the domain as the URL to use so it will always redirect you to the old server. The best solution is to change your <code> hosts </code> file. <code> 123.456.789.0 yourdomain.com </code> By using the NEW IP address you are forcing your computer to use the new server when going to <code> yourdomain...
Wordpress backup(on another server)leading to old server addy and WP
wordpress
I am using version 3.3.1 of wordpress but I'm following a tutorial that used version 2.7. After changing my header.php and comments.php code, I'm getting an infinite loop when I view the single post page with comments. Here is the change I made in the <code> &lt;head&gt; </code> tags in header.php: <code> &lt;?php if(i...
The article you're using is quite old, from ~2009. There are much better cleaner ways of doing commenting. As a guide, follow this: http://ottopress.com/2008/wordpress-2-7-comments-enhancements/ This is the definitive guide to implementing Comments post v2.7, and Otto is widely respected in the community. Firstly, your...
infinite loop on page with comments after changing comments.php and header.php
wordpress
Is there a way to make WordPress process Full size images, which by default it leaves unmodified?
Yes, there is. Found here: http://www.wprecipes.com/how-to-automatically-use-resized-image-instead-of-originals It will replace the original picture with the <code> large </code> size, defined in Media Settings ( <code> /wp-admin/options-media.php </code> ). Here's the code: <code> add_filter('wp_generate_attachment_me...
Auto-modifying original [full size] images
wordpress
I am currently using the following function to list the children of a page, however the function recursively finds children of the children and I only want to list the direct children of <code> $post-&gt;post_parent </code> . <code> wp_list_pages(array('child_of' =&gt; $post-&gt;post_parent,'exclude' =&gt; $post-&gt;ID...
Try this: <code> wp_list_pages(array('child_of' =&gt; $post-&gt;post_parent,'exclude' =&gt; $post-&gt;ID, 'depth' =&gt; 1)) </code> Read the codex for more details.
List direct children of page
wordpress
We have some sites where we note a few things that need to be checked or done either before or immediately after a core, theme or plugin upgrade. While I keep a list of these things, sometimes users themselves do the upgrade and mess everything up. I was hoping to be able to add a message to the upgrade screen to remin...
There is an action, <code> 'core_upgrade_preamble' </code> , which can be added to output anything you would like at the bottom of the upgrade-core page. For example, try: <code> add_action('core_upgrade_preamble', 'add_custom_upgrade_core_message'); function add_custom_upgrade_core_message(){ echo "&lt;p&gt;HI THERE&l...
Is there a way to hook into the update-core page for custom messages?
wordpress
Is there a hook/function combination that can be added to my theme's <code> functions.php </code> to properly disable REVISIONS and AUTOSAVE for the entire wordpress installation? What about if just for a certain custom post type? Searching online gives various hacks from deregistering scripts to tampering with core fi...
This should be placed in your wp-config.php (and no where else): <code> define( 'AUTOSAVE_INTERVAL', 60*60*60*24*365 ); // autosave 1x per year define( 'EMPTY_TRASH_DAYS', 0 ); // zero days define( 'WP_POST_REVISIONS', false ); // no revisions </code>
How to properly turn off REVISIONS and AUTOSAVE for whole site and optionally for a custom post type only
wordpress
what wp function do i use so that I can delete a term without worrying about the related tables such as wp term relationships and wp term taxonomy? Also if a post has a relationship to the deleted term and it's the only relationship to any term does wp take care of the necessary and it's associated back to uncategorize...
Use this: <code> wp_delete_term </code> Edit: Did a little dig around. With custom taxonomies, if you delete the term, the posts will not be assigned a new one. With 'category', whichever you set as the default from 'Writing Settings' will be assigned to the post. Besides, if you want to set the default category from c...
Deleting terms from the Wordpress wp terms table
wordpress
I'm trying to use <code> is_plugin_active </code> within functions.php. I need to wrap my <code> useragent_shortcode </code> function within <code> is_plugin_active </code> because when Contact Form 7 gets deactivated, I get a white screen. I've included <code> wp-admin/includes/plugin.php </code> as shown in other WPS...
This works: <code> If (in_array( 'contact-form-7/wp-contact-form-7.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { function useragent_shortcode($tag) { if ( ! is_array( $tag ) ) return ''; $options = (array) $tag['options']; foreach ( $options as $option ) { if ( preg_match( '%^name:([-0-9...
Using is_plugin_active within functions.php
wordpress
Weird question here, but I'm hoping somebody is familiar with the issue. When an admin clicked on the "approve" link under a comment on the comment moderation screen, the entire comment row turned red. The comment did publish--but the "approve" link was still appearing in the list of actions links (when it should have ...
Got it figured, so I'm closing this question out. Here was the problem: on comment approval, I had some custom stuff hooked, and this custom stuff was throwing an error. This error was being included as part of the comment approval's AJAX response. It turs out that on listings pages in the admin, if WordPress encounter...
Why might a comment turn red on approval?
wordpress
As we all know, the twenty-eleven theme comes with a random banner feature which, if the site visitor clicks it, takes him to the home page. So there could be quite a few different images for the banner, but they all take you to the same URL when you click them. What I would like to have is that each banner image will ...
I recommend you register a post type called 'header_slide' and use the featured image of said posts as the banner. Do a query with a maximum of 1 post per page and display the banner, and add the url as a custom field. Something similar to this: <code> $q = new WP_Query(array( 'post_type' =&gt; 'header_slide', 'posts_p...
How to change the URL of a clickable banner?
wordpress
I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats). How would I implement <code> has_post_format( 'standard' ) </code> , or something similar, into the code below? I haven't been able to find a query for <code> get_posts </code> that only requests specif...
You can't actually pass a taxonomy-related argument to <code> get_posts() </code> . (Edit: actually, yes you can. The Codex is just somewhat unclear. Looking at source, <code> get_posts() </code> is, at its heart, just a wrapper for <code> WP_Query() </code> .) You can pass meta keys/values, and post types , but not ta...
Only get_posts of certain post formats
wordpress
I'm grabbing a post based on a querystring parameter. How can I get the neighboring posts for a previous and next button? This will get tricky when you're on the first/last items. Here is how I'm getting the target post: <code> $the_id; if($_GET['the_id']) $the_id = $_GET['the_id']; $arr = array('post_type' =&gt; 'my_c...
use get_adjacent_post() . if nothing is returned for next/prev, get the first/last. Edit- just noticed your custom post type, you'll also have to filter <code> get_previous_post_where </code> and <code> get_next_post_where </code> to pick up your cpt.
grab neighboring content in a query
wordpress
I created a custom-taxonomy for a custom-post-type which functions as kind of categories for this post-type. The Metabox for my taxonomy has two tabs. One for my Categories and a second tab called "Most Used" just like the normal categories for normal posts has. Is there a way to get rid of this "Most Used" tab? Thanks...
Yes - you need to first 'de-register' the metabox WordPress automatically creates: <code> add_action( 'admin_menu', 'myprefix_remove_meta_box'); function myprefix_remove_meta_box(){ remove_meta_box('my-tax-metabox-id', 'post', 'normal'); } </code> Where <code> my-tax-metabox-id </code> is the ID of your metabox. Then '...
Custom-Taxonomy as categories: Remove "most-used" tab?
wordpress
Thanks to stackexchange-url ("this answer here"), I am able to use different instances of <code> wp_editor </code> to determine which buttons each of my differing TinyMCE instances use. However, I'm struggling to actually get my buttons registered - they're simply not appearing on the TinyMCE interface the way I think ...
I copied your code into my functions.php, and added a simple admin panel ('Foo') to display the editor. Then I created a new directory inside my current theme for the editor button, and put the editor button JS into the relevant file: <code> /wp-content/themes/[my-theme-dir]/tinymce_buttons/pH/editor_plugin.js </code> ...
Registering custom TinyMCE buttons, for admin area, to work with custom instances of wp_editor
wordpress
I am working on a client's site and they need to select a Template whenever they are adding a new page; the "Default Template" is not a valid choice. I would like to rename "Default Template" to something like "-- Select Template --". Searching the WordPress codebase I found references to "Default Template" are hard-co...
Your request, if I'm not mistaken, is to create an empty selection as the default for the page template drop-down, then force a user to select a custom page template. This may be an over-simplified answer, but you should create a default template that is a valid choice, then offer other templates to supplement the "Def...
Change the name of the 'Default Template'
wordpress
I have some clients that are going to be using wordpress for their sites. I created custom fields for them to input data in so they don't have to use the editor. How do I hide the page editor completely? I want it completely hidden so they don't accidentally muck things up. Thanks!
For posts: <code> add_action('init', 'my_custom_init'); function my_custom_init() { remove_post_type_support( 'post', 'editor' ); } </code> See Codex . For custom post types that you register, you can specify what 'features' it supports when you register it it use the 'supports' arguments. For custom post types that ar...
How To Hide The Visual And Html Editor Completely?
wordpress
I have built a wordpress site and theme and have several pages that I do not want editors to edit. However, there are other pages that I want them to have access to edit. Is there a plugin or code that will lock certain pages from being edited by anyone other than the admin?
Have a look at the Members Plugin by Justin Tadlock. It has a " content permissions " feature, that let's you restrict posts and pages by user role. Alternatively, if you wanted to implement this yourself, you could write a shortcode that redirects the user conditionally. And place that on pages you want to restrict. S...
Is there a way to lock certain pages from being edited by anyone other then the admin?
wordpress
Quite suddenly our company site began throwing a 301 redirect error. I've disabled our most recent plugin additions (old additions) and have looked for any kind of recent code adjustments in the theme that might have contributed to the problem. Nothing obvious. As a quick fix, I installed Mark Jaquith's Permalink Fix &...
Looks like CloudFlare just went live. Any idea what the cause of the troubles is. It would sure be nice to have some kind of inocculation. Okay in that case, CloudFlare requires that you use the "Add WWW" option here. However, if your WordPress install isn't told to do the same, they conflict and result in the infinite...
Endless Redirects Suddenly Disable Site
wordpress
I'd wish to use WP 3.x standard Media Librery rather than relying on 3rd party plugins like NextGen no matter how well they're written. I just don't like duplicating functionalities. Media Librery actually can handle well images, provides thumbnails, captions... But I think lacks of organizing images in collections, fo...
I've had this same problem for ages and have currently landed on the following combination of plugins to resolve the issue: Media Tags Tag Gallery Cleaner Gallery Additionally, I made two modifications to the tag gallery plugin ( to remove TimThumb and allow reverse ordering ) This solution still has a lot of downsides...
Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms...)
wordpress
I have two Wordpress installations that I would like to make into one installation, but still keep the posts (and their meta-data) separated. Both installations currently share the same database. I would like to be able to loop through both blogs, but each on their own page. I have extracted both databases using the bu...
When you choose to import them into the new/merged website, you'll have the option to import the author, or to assign a new one to the imported posts. You could assign different authors to each import and use that to separate the content. Do both use the same categories? If they don't it should be simple since they wil...
Merge two WordPress installations into one, and keep posts separated?
wordpress
Yesterday I logged onto my site and found that when I log in as an admin I get a 404 error as seen below: I have done a bit of research and uploaded a backup, modified my <code> .htaccess </code> file to below: <code> # BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.ph...
One possible reason is that the /wp-admin has been reset to something else, for security reasons. The WP Better Security plugin can do this. I know, because I have in the past turned on a bunch of this plugin's options, without thinking too much about it, including the one that re-writes the /wp-admin URL so you need t...
wp-admin redirects to 404
wordpress
On my NFL football blog all users are allowed to make blog posts. New registrants are given contributor status. When users make a post it is reviewed by an editor, then the editor schedules the post to publish at a time fitting our blog schedule. Multiple editors have asked me if they could make a comment on the articl...
Through the stackexchange-url ("thought process initiated by userabuser"), more research and trial and error, I have come up with a solution. I have added a custom meta field using Easy Content Types (simply because I have used this plugin for a while) and added the following code to my functions.php <code> if (current...
How can I allow editors to leave comments on posts that have not yet been published?
wordpress
Does anyone know how to exclude/filter a tag from the HTML string generated by get_the_tag_list()? http://codex.wordpress.org/Function_Reference/get_the_tag_list Any help much appreciated.
<code> function mytheme_filter_tags( $term_links ) { $result = array(); $exclude_tags = array( 'some tag', 'another tag', 'third tag' ); foreach ( $term_links as $link ) { foreach ( $exclude_tags as $tag ) { if ( stripos( $link, $tag ) !== false ) continue 2; } $result[] = $link; } return $result; } add_filter( "term_l...
How to exclude/filter a tag from get_the_tag_list()
wordpress
I have the following code but I always get an error, it's the first time I've tried to merge HTML with PHP: <code> &lt;?php if(get_field('post_image')) { echo '&lt;img src="'. get_field('post_image') .'" /&gt;'; } else { echo '&lt;img src="&lt;?php bloginfo('template_url'); ?&gt;/images/images/default.jpg" /&gt;'; } ?&...
You get the error because you try to call php inside php. Try to use this snippet and see what is different: <code> &lt;?php if(get_field('post_image')) { echo '&lt;img src="'. get_field('post_image') .'" /&gt;'; } else { echo '&lt;img src="' . get_bloginfo('template_url') . '/images/images/default.jpg" /&gt;'; } ?&gt;...
HTML in PHP problem
wordpress
When I query the category (category.php), how to get the name of the current category, ie., the one that is being queried? And for tag and date (be it the day, the month or the year)? Thanks!!
For category use <code> single_cat_title </code> function: http://codex.wordpress.org/Function_Reference/single_cat_title For tag use <code> single_tag_title </code> function: http://codex.wordpress.org/Function_Reference/single_tag_title For date use <code> get_the_date </code> function: http://codex.wordpress.org/Fun...
How to get category and archive title?
wordpress
I have a site that uses custom database tables to manage info that is inserted by a process completely independent from Wordpress. The data from the table is used in the Wordpress site but it is not manageable through the Admin interface. I want to make it manageable via the admin backend. What is the basic process for...
Some notes before: This is only how I'd approach it - I'm not going to step more into detail, because basically it's a list of plugins you'll have to code. Build a Back-End page Use the function <code> add_menu_page </code> to add a page. Then build your management tables extending the <code> WP_List_Table </code> clas...
Edit Custom Database Tables in Wordpress
wordpress
I am new to WordPress plugins. I have installed "Now Reading Reloaded" Plugin. My objective is to display bunch of books which i am reading or referring on a separate page : Books. I have installed, Activated, Also registered the Amazon Web Services Access Key ID. How to set the Plugin to the Books Page and make the li...
Read the docs for the plugin. You need to use the template files (included with the plugin in the templates folder). You need to and modify the html and php to match your own theme's template files so you can use them in your own theme and have the pages look like your own theme's design.
Using Amazon Book Gallery Plugins in Wordpress
wordpress
I'm importing a csv file via the database, all the posts are unpublished when I look in the CMS, is there a way to make them automatically published on import? Doing a bulk publish via the CMS doesn't work as I need the dates I've put in the CSV file to be the publish date, not the date publish was clicked. In the post...
Suggestions for what you can try: Try to remove the empty columns, especially post_excerpt. Try another import plugin. Try another delimiter.
Importing posts via MySql (a csv file) need to be automatically published
wordpress
This is not a programming question. I have the problem to update the content in my WordPress blog. I'm very aware this problem can be solved by html modification. But my client doesn't know about html.So i need to give him relevant solution. My Problem :- I want to show my content as below screen. But While i insert a ...
You need to setup CSS settings for <code> alignleft </code> class of your theme: <code> .alignleft, img.alignleft { /* ... */ display: inline; float: left; /* ... */ } </code> And you need to add editor stylesheet where the same CSS will be presented. Create <code> editor-style.css </code> file in your theme, put conte...
Float images in content
wordpress
I've just looked into wordpress code and found this definition of add_action: <code> function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return add_filter($tag, $function_to_add, $priority, $accepted_args); } </code> Now why are we wasting one CPU cycle for just calling another function th...
Actions do things. Filters modify things. You do stuff in an action, whereas if you apply a filter, you do not expect any events or actions to occur, other than the modification of the value you're filtering. e.g. It's not okay to send an email or save a DB value in a filter, but it is okay in an action. There may be r...
Whats worth using add_action when we can simply use add_filter?
wordpress
I am grabbing two sets of custom meta and looping through the posts, order goes: custom meta1, posts, custom meta2. but for some reason the second set of custom meta wont show up if I add the posts loop. does custom meta have to be within the loop? it seems to work if there is no loop call. here is what my code looks l...
You have to <code> wp_reset_postdata() </code> after your custom loop to restore the global <code> $post </code> variable.
adding custom meta as well as looping through posts
wordpress
I have a client who bought a wordpress theme that is built for posting job listings, a user can create an account and then post job listings but my client wants it converted to post Wheel listings (car wheels). I have converted it pretty well so far but I need to allow the user to upload an image for a listing. A listi...
You might want to check out this resource which provides a relatively simple and easy to understand snippet to achieve just that! Link to the original source from @Matthew Price. I have pasted the code below for the purpose longevity but please note this is not my code nor am I taking credit for its authorship. <code> ...
User facing form to upload image on wordpress
wordpress
I'm using gravity forms to take mp3 submissions but doing it like that seems to be extremely intensive on my site especially when multiple people are doing it one time and streaming the content aswell. Is using amazon cloudfront to stream the media going to make a big difference and what's a good technique for taking u...
The right way is entirely dependent on what limitations you want to place on your users. WordPress ships with a library called plupload . This is what powers the multi-file uploader in core, and it's available to create your own upload tools as well. The beneficial feature of plupload is the ability to chunk files on t...
How to take large file uploads from users the right way
wordpress
I have a custom post type for a cycling club uses to schedule rides. There is a custom field for these posts where the user selects the "ride date" with JQUI date &amp; time picker. This information is stored as such in postmeta: <code> 07/26/2012 @ 12:00 am </code> I query these posts with: <code> query_posts(array('p...
I would suggest storing the date-times as either: Timestamp (to sort/compare by <code> meta_value_num </code> ) 'yyyy-mm-dd hh:mm (e.g. 2012-04-11 19:37) to sort/compare by <code> meta_value </code> Then the following will work (assuming you're using timestamp): <code> $now = current_time('timestamp'); $args = array( '...
query_posts, oderby meta_value & print "future" posts
wordpress