question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
What is the difference between these two methods of writing $ instead of jQuery in WordPress <code> (function($) { // $ Works! You can test it with next line if you like // console.log($); })( jQuery ); </code> ... Which I found here and <code> jQuery(function ($) { /* You can safely use $ in this code block to referen...
The first is a pattern called a closure . It's not unique to jQuery. You could just as easily write <code> (function(someVar) { // Inside the closure, someVar == "test" })("test"); </code> Basically, you're manually passing jQuery into the closure by referencing the <code> jQuery </code> object externally and aliasing ...
What is the difference between these two methods of writing $ instead of jQuery in WordPress
wordpress
I've got a function that I'm trying to fire at wp_signon (grabs data from a remote server and updates accordingly). I'm running the function within a class that is on a secondary file in a plugin (i.e. brought in with a require_once). For the life of me, I cannot get this function to run at all. <code> add_action( 'wp_...
wp_signon doesn't exist (at least according to http://codex.wordpress.org/Plugin_API/Action_Reference ) but I tried tossing this into a fresh theme and it seems to work: <code> class TestThing { function __construct() { add_action( 'wp_login', array($this, 'login_pull_updates') ); } function login_pull_updates($login, ...
firing function at login within class
wordpress
I'm developing a website using WordPress 3.3.2 and have the Front Page and Posts Page set to use static pages. I'm trying to show different menus using <code> wp_nav_menu() </code> for the static front page and static posts page respectively. I was able to find <code> is_front_page() </code> to check for the front page...
There are two options: <code> // If the current page is the blog posts index, // but is NOT the site front page if ( is_home() &amp;&amp; ! is_front_page() ) </code> or <code> // If the current page has the ID of the // page assigned to display the blog posts index if ( is_page( get_option( 'page_for_posts' ) ) </code>
Check if Currently on Static Posts Page
wordpress
<code> $key = "key"; $meta_boxes = array( "item-count" =&gt; array( "name" =&gt; "item-count", "type" =&gt; "itemcount", "std" =&gt; "", "title" =&gt; "How many items?", "description" =&gt; "Choose item count", "options" =&gt; array( "0" =&gt; "None", "1" =&gt; "1", "2" =&gt; "2", "2" =&gt; "2", "3" =&gt; "3", "4" =&gt...
Your first line reads: <code> $key = "key"; </code> And your last line reads: <code> update_post_meta( $post_id, $key, $data ); </code> So, for all I can see here, if you change it to: <code> $key = "item_color"; </code> You should be good to go.
Saving metabox keys and storing values as array
wordpress
Today I came over a very interesting and confusing problem. I developed a wordpress website in my localhost and it run perfectly. But when I moved that site in my server I saw a strange thing. When I logged in my admin panel (..wp-admin/index.php) my toolbar isn't showing up and any widgets that were showing fine in th...
I've a solution of my problem. I used chrome developer tool to find out the differences between the sites in my server and in my localhost. While inspecting the source I found following error- <code> &lt;div class="inside"&gt; &lt;br&gt; &lt;b&gt;Fatal error&lt;/b&gt;: Out of memory (allocated 43778048) (tried to alloc...
Top toolbar is not showing in wordpress admin panel
wordpress
From time to time, I feature posts from the archives. Sometimes, I need to feature items 2 3 years back. In order to feature such posts, I simply categorized them into the <code> featured </code> category and once I am done featuring them, I unchecked them from the <code> featured </code> cat so I can have the room to ...
as moraleida mentions, your setup is a custom implementation specific to your theme, not native to WordPress. rather than use a category, I would use post metadata to designate posts as featured. I would additionally create a custom meta box to designate the post as featured, that way, on the back end, I can store when...
handling the featured category
wordpress
I have a search page that display's news items using the loop below, how can I only show posts with the status "future"? <code> &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;div &lt;?php post_class(); ?&gt;&gt; &lt;div class="news-item" onclick="location.href='&lt;?php echo the_permalink(); ?&gt;'"&gt; &lt;h2&g...
Something like this might work: <code> &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php if ( 'future' === get_post_status( the_ID() ) ) : ?&gt; &lt;div &lt;?php post_class(); ?&gt;&gt; &lt;div class="news-item" onclick="location.href='&lt;?php echo the_permalink(); ?&gt;'"&gt; &lt;h2&gt;&lt;a href="&lt;?php e...
Display future posts in search
wordpress
We've inherited a WordPress (3.3.2) site that has 13k pending comments, all of which are spam. To delete all these comments is it sufficient and safe enough to do: <code> DELETE FROM wp_comments; DELETE FROM wp_commentmeta; </code> ...or alternatively <code> TRUNCATE </code> both tables in the database?
Yes. That will be sufficient. And I highly recommend that you activate the Akismet plugin to block spam. Probably if you think there might be any genuine comments in the 13k pending ones, then install and activate Akismet first. Then go to Comments in the Wordpress Dashboard, and click on 'Check for Spam'. It should au...
What is the correct/safe way to delete all comments?
wordpress
I have situation, that i need common user login for Blog A Blog B bbPress I found the solution Single use login for two wordpress installation from Justin Tadlock Blog. Installing two WordPress blogs with the same users But What for bbPress ? Is there any plugin can work for me ? Should i use wordpress multisite (i am ...
Multisite User Management This plugin works for me! Automatically add users to each site in your WordPress network.
Common user login for two different wordpress installation and bbpress
wordpress
This question is all about finding out the best way to handle merging similar terms. Let's say you have 10 posts tagged as <code> Barack Obama </code> and 20 posts tagged as <code> Obama </code> . and you want to group them all under <code> Barack Obama </code> and get 30 posts for it and get rid of the tag <code> Obam...
The plugin Term Management Tools will allow you to merge tags.
merging terms programmatically while maintaining the count
wordpress
I have the following code. When There is only one image in the backend, the second image shows up with a little question mark instead of nothing. I am looking for a way to check if the image exists first and if so run the code and if not don't. <code> &lt;?php $image = wp_get_attachment_image_src(get_field('post_image1...
wp_get_attachment_image_src will return false if there is no image. So before you echo the image add <code> if ($image !=false) </code>
If statement to check if post has image
wordpress
Overview : I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself. Details : I have added a custom meta_key "price" to all my posts. The value is always an integer (no decimals or non-numeric characters). I am trying to do a query t...
The meta_value is not of an integer type for max to return proper values. You can use mysql <code> cast </code> method to convert into integers as follows: <code> SELECT max(cast(meta_value as unsigned)) FROM wp_postmeta WHERE meta_key='price' </code>
SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'... stops working when value is over 999
wordpress
I need a plugin (or other) recommendation to allow users to create email accounts, as well as change their passwords and check their email using WordPress. I have a multi-author baseball website and I would like to allow authors to create their own email addresses at my domain name, if they like. That being said, I do ...
I've successfully used this to enable users to create an email account and/or ftp account on cpanel from within a WordPress site. Good luck, and let me know how it went. There seems to be a small bug in the latest plugin version. You can easily fix it, I've described the steps below: Open your code editor Open up searc...
Create/Edit/Check cPanel Email Accounts from Wordpress
wordpress
What I want to do I want to upgrade Wordpress programmatically to a later version. That I want to do with PHP, lets say from http://www.example.com/?upgrade_wp=true I already know how to get the URL of the latest version so I don't having any problem with checking for versions or finding the right URL. Answers I want A...
A hint to the functions that I need to use. I'm not sure why you'll want to mimic WP's default behavior, but most of the update logic lies on <code> wp-admin/update-core.php </code> Check for <code> do_core_upgrade() </code> .
Upgrade wordpress core programmatically with PHP
wordpress
After making a lot of little changes to the current custom theme [zeeBizzCard] I'm using, I want to reset it back to it's original style. Being new to WP, I didn't make a backup of the default theme and can not find a quick and easy method of reseting the theme. Have I missed something, or is there no "reset" options f...
If you look into the file <code> includes/admin/theme-admin.php </code> you’ll see that the theme’s options are stored in <code> 'themezee_options' </code> . You can either delete these options per database manager or per a plugin. If you aren’t familiar with database operations, copy the following code into a PHP file...
How to reset a custom theme
wordpress
I'm trying to modify wp_nav_menu to display term thumbnails. To get those thumbnails I need term ID and taxonomy slug: <code> $thumbnailimg = get_the_term_thumbnail($term_id, '$taxonomy', 'medium'); </code> I managed to get term ID for it with: <code> $term_id = (int)$item-&gt;object_id; </code> But now I need to check...
For a menu object <code> $item </code> : <code> $item-&gt;object </code> stores the object the menu item refers to, e.g. 'post', 'page', 'my-cpt', or 'my-taxonomy' (the post type name, or the taxonomy name) <code> $item-&gt;type </code> stores what 'type' of object is it, either: 'post_type' or 'taxonomy'. For custom l...
Taxonomy slug by term ID
wordpress
With the following shortcode for YouTube videos, how can I make it such that WordPress still automatically embeds the video for me? <code> &lt;? /** YouTube shortcode, usage: [youtube align="alignleft" id="123456789" ] */ function shortcode_youtube($atts) { extract(shortcode_atts(array( "id" =&gt; '', "align" =&gt; 'al...
There may be a more graceful way to do this, but it works: <code> function shortcode_youtube($atts) { extract(shortcode_atts(array( "id" =&gt; '', "align" =&gt; 'aligncenter' ), $atts)); global $wp_embed; $content = '[embed]http://www.youtube.com/watch?v=' . $id . '[/embed]'; $embed = $wp_embed-&gt;run_shortcode( $cont...
Forcing WP to embedd a video when using a shortcode
wordpress
I would like to know if there is a way to get a rss feed when one of the plugin of my website is available. Indeed, I need to manage updates of some website, but I don't want to lose my time connecting on those websites to see if there are really some plugin updates... So getting a rss feed would be perfect. Is it poss...
If your main goal is to get notified in new plugin updates, then you can easily accomplish this with a plugin. Update Notifier. http://wordpress.org/extend/plugins/update-notifier/
Get RSS feed about plugin new update
wordpress
My client's home page displays a paginated list of posts with thumbnails. Each list item, when clicked, navigates to a single post or page, and then uses a separate query to generate the same list of posts at the page footer. Pagination works just fine on the home page, however, he wants the list underneath single post...
From the WordPress Codex, I believe you want the function paginate_links http://codex.wordpress.org/Function_Reference/paginate_links Example: <code> &lt;?php echo paginate_links( $args ) ?&gt; </code>
How can I paginate a list of related posts?
wordpress
I want to make an exception for my custom taxonomy order. Sometimes you need to put "Other" option as last option but when calling taxonomies with "orderby=name", sadly "Other" term is not listing as last option. Is there any proper way for this exception?
Here is the example of <code> get_terms </code> in the Codex: <code> $terms = get_terms("my_taxonomy"); $count = count($terms); if ( $count &gt; 0 ){ echo "&lt;ul&gt;"; foreach ( $terms as $term ) { echo "&lt;li&gt;" . $term-&gt;name . "&lt;/li&gt;"; } echo "&lt;/ul&gt;"; } </code> Lets say there was an 'other' term in...
Taxonomy order exception for specific term
wordpress
I have 2 blogs, one which is multisite and one which isn't. I want to get a list of plugins active on both the blogs so I can compare them. On the multisite blog, I want to list the plugins which are enabled network-wide as well as site wide.
The activated plugins are stored in the options table of a WordPress Blog under the key <code> active_plugins </code> so you can use <code> get_option('active_plugins'); </code> of each blog and compare the arrays.
How to do I get a list of active plugins on my wordpress blog programmatically?
wordpress
I'm working on a IP Locator Service, and I want to display a Customized Google Map which shows the visitor's location. It works fine here , but I don't know how to incorporate it into my Blog. I've got the "html/javascript in Wordpress" Plugin, but I also need to apply a few Meta tags to the page. Is there any plugin/t...
You have two options. Both involve using a conditional tag . I don't know which conditional you'll need to test for, hence the "{something}" placeholder. (If I had to guess, you may use the <code> is_page( $ID ) </code> tag.) Edit your theme header file. It's usually called <code> header.php </code> : <code> if( is_{so...
Apply a Meta tag to one page only
wordpress
I installed last version of wordpress by activating network. I can upload images or any media and insert into posts, But when I publish that, medias including images or any other media. My htaccess file includes: <code> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f Re...
The correct <code> .htaccess </code> for a multi-site setup looks like this: <code> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] R...
pictures does not apeare in posts
wordpress
I am trying to make my custom post type display on the front end as if it were a page. Depending on the theme, it won't have the date, author, etc... I've looked into creating a template such as 'single-&lt;CPT&gt;.php'. But that's too static to work for any theme design. Is it possible to somehow tell the current them...
There are a number of template filters you can use to alter the template hierarchy. Have a look at the template hierarchy page at the filters and example provided. Here's a modified version of the example that uses <code> single_template </code> . It checks for a specific custom post type and loads the theme's <code> p...
Make custom post type display as a page
wordpress
By submitting a post for publication will be made a count of the number of words in the post and will add a div with font-size pre-set according to the number of words. If the post contains up to 50 words, returns with font-size:18px; <code> &lt;div style="font-size:18px;"&gt;&lt;p&gt;Text with up to 50 words.&lt;/p&gt...
Filter <code> 'the_content' </code> , stackexchange-url ("count the words"), and add the markup you need. You should not use <code> str_word_count() </code> because it has issues with numbers and utf-8. So let’s start with a word count function: <code> /** * Alternative for str_word_count(). * * @link http://toscho.de/...
Set font size automatically according to number of words in post
wordpress
I've created a filter to alter <code> the_title </code> hook in one of my custom post types (thanks Chip Bennett for the snippet). The function is supposed to tell Wordpress to call the title from a custom field ( <code> _location </code> ) within my custom post type page. The problem is that all of my pages and posts ...
Your call to <code> get_post_type() </code> needs to be passed the <code> $post </code> object, which you don't globalize until later. Try globalizing the <code> $post </code> object earlier. Also, try using <code> foo != bar </code> instead of <code> ! foo == bar </code> : <code> function change_title ( $title ) { glo...
Custom post type filter is being applied to all of my posts
wordpress
These are the functions I use in my theme to display the "entry-meta" which includes published and last modified dates (among others) of an article: <code> // Shows Author and Published Date if ( ! function_exists( 'reddle_posted_on' ) ) : function reddle_posted_on() { printf( __( '&lt;span class="byline"&gt;Posted by ...
The issue is that for correct output WP needs to process date through <code> date_i18n() </code> function. When you use date format, hardcoded in PHP code (not simply saved in PHP <code> DATE_* </code> constant) like <code> 'c' </code> - it's not available to your code and so for WP to process. System-wide fix would be...
Why time functions show invalid time zone when using 'c' time format?
wordpress
I'm trying to chang my custom search url for SEO purpose. I found an article about how to change <code> mydomain.com/?s=query </code> to <code> mydomain.com/search/query </code> . However, i prefer to have a custom search url such as <code> mydomain.com/something/query </code> . Is this achievable? Thank you for any he...
It's easy. Just add this hook for <code> template_redirect </code> action and it will redirect your search queries to nice url: <code> function wpse8170_search_url_redirect() { if ( is_search() &amp;&amp; !empty( $_GET['s'] ) ) { wp_redirect( home_url( "/something/" . urlencode( get_query_var( 's' ) ) ) ); exit; } } ad...
Wordpress custom search url
wordpress
I just need to create a blog I have done everything i guess, its showing posts but they are supposed to be kind of summary first and after click the whole post. I already selected the "For each article in a feed, show summary" from reading option from dashboard I already activated the hidden option of enabling excerpt,...
To show excerpts on home page and all archive pages, open <code> content.php </code> and modify the following line: <code> &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyeleven' ) ); ?&gt; </code> with this: <code> &lt;?php the_excerpt(); ?&gt; </code>
Show Excerpts In Twenty Eleven Theme
wordpress
I have a wordpress site say at www.demo.com, now I have two themes one which I want to use this user is acessing the site from "PC" (computer) and a another theme, which is a full fledged mobile theme to be used only when the user is accessing from a mobile device ( such as an android phone, iphone, ipad or tablet). I ...
If you don't mind getting your hands dirty with code you could combine both themes into the same folder. IE: wp-content/themes/yourtheme/secondtheme Then add the code in the header.php for your primary theme to check if its a mobile site and send the user to wp-content/themes/yourtheme/secondtheme/index.php Probably a ...
Can i have a single wordpress site to have two themes ( one for pc other for mobiles)
wordpress
I created a picture gallery at: http://ellenandjosh.com/?page_id=5 . Currently, I have a loop that displays pagination after a certain number of images : http://pastebin.com/N6nRRUei . Normally this works fine...but normally I don't have images that are different widths. WordPress crops the image by height, the width i...
It is definitely possible!! Ok, here is what I did... My new loop looks like: <code> &lt;?php $ids = array();?&gt; &lt;?php foreach(query_posts("category_name=photos&amp;showposts=-1") as $post_blog): ?&gt; &lt;?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog-&gt;ID), 'gallery-full' ); ?&gt; &l...
Gallery Pagination by Row
wordpress
I want to create multiple subdomains for users. I know how to create multiple subdomains manually using creating network . But, i have so many users, I can't create those subdomains manually one by one. I have a user list in an Excel file: <code> id || username || password || subdomain 1 || alex || **** || alex.website...
More than an answer, a study on the matter. The Excel issue we need an array, and Excel can provide a CSV a couple of solutions: stackexchange-url ("How to extract data from csv file in php?") not implemented here Relevant Q&amp;A What's common to all is: no definitive procedure has been recorded in this Stack . stacke...
Create multiple subdomains for multi-site from a database
wordpress
Is it possible to adjust the excerpt so it will show text or one image or one video? The following codes makes it possible to show all of the above, but i'd really like to limit that, dependent of whats included in the post.. <code> &lt;?php function improved_trim_excerpt($text) { global $post; if ( '' == $text ) { $te...
I would encourage you to consider using post formats. You can see stackexchange-url ("my answer to a similar question") about altering the "Read More" text, but it would apply similarly to you. For the video portion, you might want to create a custom field to hold the video URL, but otherwise, I imagine this would be q...
The excerpt: Display text OR image OR video
wordpress
I'm working with a client's WordPress site that has user submissions (via TDO Mini Forms) from multiple countries, and they would like to be able to search for posts by region – Europe, Africa, Central America, etc. There is a custom field already in place for the user's country of origin. I also have a separate table ...
You've got the right idea. If you get an array of country IDs within a region, you can pass that array to a meta query IN comparison: <code> $country_ids = array(1,2,3); // this would be the result from fetching countries associated with a region. $args = array( 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( arra...
Creating a Search Array From Multiple Tables
wordpress
I have created a table, I now need to filter the data from that table when someone selects options from a form. Whats a good way to do that?
Here is the html: <code> &lt;form name="filter" action="&lt;?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?&gt;" method="post"&gt; &lt;input type="hidden" name="filter_submit" value="Y"&gt; &lt;select name="your_filter" class="input"&gt; &lt;option value="none"&gt;nothing selected&lt;/option&gt; &lt;opti...
I have a table I created, how do I make a form for a user to filter the data?
wordpress
I'm trying to build the title of a custom post using the values within post custom fields. The problem is that using <code> title_save_pre </code> only executes when I update the post, not when I create it. When I create the post I get the title : (no title) If I edit and save I get the right title. I need to get the r...
The filter <code> title_save_pre </code> runs before the post is written to the database, and also before any of its post meta is saved to the database. So <code> get_post_meta </code> at this point will be blank for the first run, and always return 'old' data. To correct this you'll want to hook into <code> save_post ...
title_save_pre on post publish
wordpress
I'm too angry about this problem to see it straight anymore, so I'm guaranteed to be overlooking something simple. Please help. Here's all my code has been stripped down to: <code> &lt;?php $home_gallery = new WP_Query(array( "posts_per_page" =&gt; 2 )); if ( $home_gallery-&gt;have_posts() ) : while ( $home_gallery-&gt...
I finally figured this out. It's simple, too. As I posted it, that loop would never finish because there's nothing advancing the counter inside the while loop. But if I uncomment my fairly normal-looking code and run it, it still wouldn't close, because I'm not advancing the specific Query object's counter . When you r...
Why would a completely normal loop give offset errors and maximum execution time errors?
wordpress
Is it possible to fire a wordpress hook programmatically? Specifically I'd like to have control of wp-insert-post.
To fire a hook you can use following functions: <code> do_action </code> - executes a hook created by add_action. <code> do_action_ref_array </code> - execute functions hooked on a specific action hook, specifying arguments in an array. This function is identical to <code> do_action </code> , but the arguments passed t...
Fire a hook programmatically
wordpress
First time posting here... I am trying to figure out if there is a hook or action that I can use when a user goes to wp-admin/post.php... Basically when the user goes to post.php I want to check if there is a &amp;from=1 variable and add that to post_meta Thanks! <code> $from = $_GET['from']; $post_id = $_GET['post']; ...
You can add your code to the <code> init </code> action hook and check global <code> $pagenow </code> variable: <code> add_action( 'init', 'wpse8170_check_from_var' ); function wpse8170_check_from_var() { global $pagenow; if ( 'post.php' != $pagenow || ! isset( $_GET['post'] ) || ! isset( $_GET['from'] ) || 1 != (int) ...
Looking for a hook for post.php
wordpress
I'm working on a plugin for showing users via shortcode by their role (in this site's case - authors). I'm getting a list of user objects using a WP_User_Query statement, then creating the output for each user like this: <code> foreach ( $users as $user ) { ?&gt; &lt;div class="sap_author_box"&gt; &lt;div class="sap_au...
You forgot to <code> echo </code> it: <code> &lt;?php echo get_avatar( $user-&gt;user_email, 150 ); ?&gt; </code>
get_avatar not working
wordpress
Is it possible to obtain a list of which Top Level Admin Menus have been registered via some plugin? I'm talking about menus registered with: <code> add_menu_page(); </code>
You can use the global variable <code> $menu </code> to see which top level menus are registered. <code> function determine_menus() { global $menu; //echo '&lt;pre&gt;'; print_r($menu); exit; // uncomment to see the array of menus in back-end } add_action('admin_init', 'determine_menus'); </code>
Determine Registered Admin Menus
wordpress
I decided to learn how to develop wordpress plugins and I am totally confused and frustrated. I've already read some good tutorials and I guess I am already familiar with the basics. Now, I want to start developing my first plugin and I decided to start with a javascript image slider. At this stage I know how to set up...
Take a look at: http://www.plupload.com/ This is the uploader that is used by WordPress in the admin area for media uploads. You should be able to hook WordPress' version in to your plugin.
How to upload multiple files/images when developing a wordpress plugin?
wordpress
I'm using the following to bring up a tag archive page: <code> &lt;?php query_posts( "tag=". '' . single_tag_title( '', false ) . '' ); ?&gt; </code> This works perfectly for all tags of one word only, but any tags of more than one word (eg: "tag one", slug: "tag-one") do not display. Is it possible to query_posts by t...
The <code> single_tag_title() </code> function returns the tag title while you need the tag slug or ID for use in <code> query_posts() </code> . This should get you started: <code> if ( is_tag() ) { $tag = get_queried_object(); $tag_title = $tag-&gt;name; // Same as single_tag_title() $tag_slug = $tag-&gt;slug; $tag_id...
Filter query_posts by tag slug on "Tag Archive" page (when tag is 2 or more words)
wordpress
We are starting to rack up the number of WP websites and we're looking to have a bit more control over all of them, would multi site be the correct way to go? All the sites are running on different domains, different versions of WP and different plugins (with different versions of those). I don't want to blanket update...
yeah, if you cant upgrade to 3.0=> then you could use something like http://managewp.com/ that adds the functions to control multiply sites from "one dashboard". Im running a big multisite for all my min-clients with separate domains etc. And its really nice to have that control of all the sites.
Running hundreds of WP in multisite
wordpress
This code worked perfectly! But my issues is that it removes text on pages. I just need the page numbering to appear immediately after the post and not at the bottom of the page. Any suggestions? <code> add_filter ('the_content', 'pagination_after_post',1); function pagination_after_post($content) { if(is_single()) { $...
Your call of <code> wp_link_pages </code> displays navigation immediately because <code> echo </code> argument is set to <code> 1 </code> by default, and it means to echo result. So try to add <code> &amp;echo=0 </code> at the ennd of <code> wp_link_pages </code> call: <code> add_filter ('the_content', 'pagination_afte...
wp_link_pages appearing after post content and not at bottom of page
wordpress
in home.php <code> // NOT working query_posts('show_posts=3'); // NOT working add_action( 'pre_get_posts', 'set_posts_per_page' ); function set_posts_per_page( $query ) { $query-&gt;set( 'posts_per_page', 3 ); return $query; } genesis(); </code> I searched a lot, almost always they say the 2nd solution. But i does not ...
1) use <code> posts_per_page </code> to set number of posts 2) your <code> add_action </code> and its associated function needs to be in your theme's <code> functions.php </code> file, not the template. the <code> pre_get_posts </code> action is the preferred method between the two, use that one.
Posts limit on homepage (genesis framework)
wordpress
I'm using the following <code> WP_Query </code> arguments array: <code> $args = array( 'post_type' =&gt; POST_TYPE, 'tax_query' =&gt; array( 'taxonomy' =&gt; TAX, 'field' =&gt; 'slug', 'terms' =&gt; TERM ), 'posts_per_page' =&gt; 2 ); </code> The problem is this query displays all the posts from <code> POST_TYPE </code...
You're one array short. The tax_query is an array of arrays. <code> $args = array( 'post_type' =&gt; POST_TYPE, 'tax_query' =&gt; array( array ( 'taxonomy' =&gt; TAX, 'field' =&gt; 'slug', 'terms' =&gt; TERM ), ), 'posts_per_page' =&gt; 2 ); </code> See http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/...
How to make WP_Query not to show irrelevant posts?
wordpress
I'm using the following query in my frontpage template: <code> &lt;?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args=array( 'paged' =&gt; $paged, 'category_name' =&gt;'home,tumblr' ); query_posts($args); </code> But for some reason, posts that are made sticky in either of these categories do ...
DO NOT USE <code> query_posts() </code> FOR CUSTOM LOOPS! Use <code> WP_Query() </code> instead. <code> &lt;?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $custom_cat_query_args = array( 'paged' =&gt; $paged, 'category_name' =&gt;'home,tumblr' ); $custom_cat_query = new WP_Query( $custom_cat_que...
Sticky posts don't show up first in custom loop
wordpress
Is there a way to customize the WordPress> error page template so that the user isn't shown just a blank screen with text? I'm not talking about 404, but when WordPress displays an error. I'd like to style this page to match my theme.
You're probably talking about theming wp_die(), which is the function that produces those grey error pages with a white box of text in them. For a plugin solution , you could try this plugin, which says it does what you want. Not sure about version support though--it says it only works up to 3.1.4. For a programatic so...
Customize WordPress> Error Page
wordpress
I want to save a meta data to post parent when the media-form on gallery tab is saved( The submission button is "Save All Changes"). Which action hook can I use?
For updates it is <code> 'edit_attachment' </code> and for new attachments <code> 'add_attachment' </code> . There is no action dedicated to images coming from the gallery tab, but you could check the global array <code> $_FILES </code> . If there is a <code> $_FILES['async-upload'] </code> it is probably a request fro...
What is the action hook for save media-form on gallery tab?
wordpress
I have my <code> style.php </code> file looking like this. <code> &lt;?php header('Content-Type: text/css');?&gt; #div{ background:&lt;?php echo get_option('bgcolor');?&gt;; } </code> This does not work, but when I do this it works. <code> &lt;?php header('Content-Type: text/css');?&gt; #div{ background: &lt;?php echo ...
WordPress functions are available only if WordPress is loaded. If you call your <code> style.php </code> directly you cannot use a WordPress function. One simple way to load WordPress for your PHP driven stylesheet is to add an endpoint to WordPress: a custom, reserved URL where you load your template file. To get ther...
How can I use WordPress functions in my stylesheet?
wordpress
I need to add an extra field to the Add New Category page. Currently it only has fields for Name, Slug, and Description. Essentially, I need to have a second description text box. I use the current Description field at the bottom of each category page, but now I need to have additional information specific to the categ...
Ended up solving this with bainternet's plugin at http://en.bainternet.info/2012/wordpress-taxonomies-extra-fields-the-easy-way
Add extra fields to Add New Category page
wordpress
I was wondering if I can include Facebook's php sdk file into a wordpress page template ? For example in page.php: <code> &lt;?php get_header(); ?&gt; &lt;?php get_sidebar(); ?&gt; &lt;!--BEGIN: wrapper--&gt; &lt;div class="wrapper"&gt; &lt;!--BEGIN: scrol left--&gt; &lt;div class="ppading"&gt; &lt;div class="scroll-pa...
Try replacing this: <code> require_once TEMPLATEPATH.'/include/facebook.php'; </code> ...with this: <code> get_template_part( '/include/facebook.php' ); </code> And if that doesn't work, try this: <code> locate_template( 'include/facebook.php', true ); </code>
Including facebook.php in a wordpress page template?
wordpress
I have a site that needs to be billingual, English and French. I've created two sites in WPMU, and set the language settings of the second to fr_FR. Under the directory: /wp-content/languages/ I have fr_FR.po and fr_FR.mo files for the Wordpress backend translations, and it is working well. I've also created a theme ca...
Have you added the Function load_theme_textdomain to the theme? so if you have them themes .mo files in theme/mytheme/languages Loads the theme's translated strings: <code> add_action('after_setup_theme', 'my_theme_setup'); function my_theme_setup(){ load_theme_textdomain('my_theme', get_template_directory() . '/langua...
Wordpress Multilingual Theme using Multisite
wordpress
How can I apply my own css (to match <code> editor-style.css </code> ) to <code> wp_editor </code> being used on the front end for comments? Currently I'm using code from here to enable the visual editor for comments. My actual code in functions.php: <code> add_filter( 'comment_form_defaults', 'custom_comment_form_defa...
Actually you can include the editor-style.css (or any other stylesheet), just pass a "content_css" value to tinymce that points to a css file: <code> wp_editor( $content, 'editablecontent', array( 'tinymce' =&gt; array( 'content_css' =&gt; get_stylesheet_directory_uri() . '/editor-styles.css' ) ); </code> So the origin...
How to add editor-style.css styling to wp_editor on front end for comments
wordpress
I'm using this bit of code on single.php: <code> $params='[gallery link="file" size="my_thumbnail_small" exclude="'.$featuredId.'"]'; $gallery = do_shortcode($params); echo $gallery; </code> But nomatter what I put in the <code> exclude </code> param, it has absolutely no effect on the output, the image that I'm trying...
You say "regardless of the params I use"... You're not using the <code> include </code> at the same time , are you? Troubleshooting ideas: use only <code> [gallery exclude="93"] </code> remove it from the Featured Image put the shortcode in the post content
gallery shortcode exclude not working
wordpress
I am experimenting some very disturbing problem using a custom SQL query. I have a custom MySQL table called <code> trading_datas </code> having 165 lines for 4,4Mo. One field <code> datas </code> of my table is a big serialized array. When requesting over it that way: <code> $querystr = "SELECT item, datas FROM tradin...
<code> $wpdb </code> is not suit for fetching huge amount of data from database. Why? In your case: <code> $wpdb-&gt;get_results( ... ) </code> - fetches all results into your RAM at once. It means if you have 4mb, 10mb, or 50mb of data in db, everything will be stored in memory (what is limited as you know). <code> $w...
get_results on large datasets
wordpress
Does anybody knows good plugin which can generate dummy posts/tags/categories/users and write dummy comments? I want to generate some content on my development (localhost) site.
I always use the Theme Unit Test that Theme Reviewers use to evaluate themes for the Repo. It's got pretty much everything you need to style/worry about. And if I need to create batch content in a different way, then I use WP Dummy Content
Content generator for development site
wordpress
I've tried over a dozen 'Contact Form' Wordpress Plugins. None of which will function and send the form contents to any email. I'm working on top of the 'PremiumPress DirectoryPress Theme' I'm thinking that the issue might be, that this theme came with a Contact Form Template (Very Terrible One), which I've removed in ...
Disable all other plugins. Use the default theme. Try again. If it doesn't send, try sending to a different (eg gmail) address. If that still doesn't work, verify that sendmail is installed. If it is, check and see if a basic sendmail php script will work. If that still doesn't work or sendmail isn't installed, you may...
Not One 'Contact Form Plugin' will send email // Work
wordpress
I have the following line under the <code> head </code> tag but I don't have the file <code> styles/default.css </code> in my theme and consequently get a loading error in browsers. I'd like to eliminate this line but I don't know where it comes from. I tried to disable all plugins but it still appears. Is this a stand...
Found it with <code> ack default.css </code> . In someone else's file that I had added to the theme.
styles/default.css in markup, where does it come from?
wordpress
Captcha, reCapthca and the like have serious usability issues. And basically anything that requires a user to fill an extra field (other than the comment) each time the user posts a comment, is considered bad usability. ( NOTE: I hope you do realize that users need only enter their name and email address once when it c...
Okay, I've (probably) done just enough reading since asking this question, and apparently this combo of anti-spam plugins, works to a very appreciable extent in mitigating spam: Akismet + Cookies for Comments + Impostercide Knowledgeable people agree: stackexchange-url ("Alex aka Viper007Bond") uses Akismet and Cookies...
Allow anonymous comments, but prevent spam
wordpress
I'm trying to write a function that will "pair" my custom post type with a page with the same name as the custom post type. The aim is that when a custom post type is saved, it checks if there's a page with the same name as the custom post type post, and if so, it pulls the id from that page and puts it as the parent i...
You have a few issues in your function. first, <code> $data </code> contains the post type, so we look there. your if statement won't work like that, you have to check conditions individually. and to find the matching page, just query by title for your page with <code> WP_Query </code> : <code> function find_parent_for...
Sets post_parent in custom post type posts automatically based on cpt-> page name
wordpress
I'm trying to build some functionality where if you're logged into an admin account you'll see a small 'edit' link next to each post title. clicking will use jquery to create 2 form inputs - 1 with the current post title and the other containing the current slug. I'd ideally like to then allow admins to edit any post/s...
Have a look at wp_ajax action hook for invoking your action. Then use update_post to update the title and slug.
How to Custom Edit Post Title & Permalink Slug?
wordpress
I want to know why Wordpress designed their database with two tables separating users and meta from each other. Wouldn't it be better if first_name, last_name, nickname, description, and capabilities are in the wp_users table? SO what's the advantage for doing this separation?
The meta table is build to allow custom user meta. If anything would be in just one table a plugin developer had to add a new column to the table for each meta data or the data had to be stored as serialized arrays/objects which would made them unsearchable. Short: Performance and flexibility.
What is the advantage of separating wp_users and wp_usermeta table?
wordpress
Anyone here see why my pagination won't work? I can get "previous page" to show up, but when navigating to "page-2", the content will stay identical to the content on "page-1". <code> &lt;?php /* Template Name: Generic Trips Template */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php get_template_part( "beforeloop", "page"...
query_posts </code> ! As Eugene pointed out, you omitted the <code> paged </code> variable. However, even with that in you can get unexpected behaviour. As illustrated by the various questions we get on <code> query_posts </code> and pagination: stackexchange-url ("query_posts and pagination, still stuck after much res...
query_posts pagination will always show identical content
wordpress
How can I get a Previous / Next navigation that only navigates the child pages of the current page? By that i mean url.com/page/ child1 , url.com/page/ child2 and so on.. I've been searching around alot but I'm still lost. It seems like you can't do that according to wordpress (they recommend plugins..)
All right, here it is, fully working: <code> &lt;?php $pagelist = get_pages("child_of=".$post-&gt;post_parent."&amp;parent=".$post-&gt;post_parent."&amp;sort_column=menu_order&amp;sort_order=asc"); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page-&gt;ID; } $current = array_search($post-&gt;ID, $pages)...
Prev/Next child navigation for current page?
wordpress
The purpose of this plugin is to create a list that users can modify with up or down votes. The shortcode is supposed to display the list on a page and use JQuery to fadeIn and fadeOut while updating the database. A demo of the concept is available at http://bucketlingerwedding.com/80s-music-reception/ (note: the worki...
You should probably write a plugin, which has the shortcode function. You can separate the AJAX/jQuery code in a plugin, but not in a shortcode.
How to put JQuery/Ajax inside shortcode?
wordpress
According to the Pinterest website in order to add the Pinterest button to any page I have to add the following just below the closing body tag: <code> &lt;script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"&gt;&lt;/script&gt; </code> What's the best way to do this? Should I follow the link, grab the...
Yes, you have to use wp_enqueue_script function. Pass <code> $in_footer </code> argument as <code> true </code> and your script will be added before closing body: <code> function my_scripts_method() { wp_enqueue_script( 'pinterest', '//assets.pinterest.com/js/pinit.js', array(), false, true); } add_action( 'wp_enqueue_...
Adding Pinterest Script Before Closing Body Tag
wordpress
I have noticed that <code> wp-includes/theme-compat </code> directory. So, what is it? Is it a theme?
The <code> theme-compat </code> directory is comprised of a set of deprecated (since WordPress 3.0) files that WordPress used to use as fallback template-part files, in case the active Theme failed to include them. In other words, if a Theme used the <code> get_header() </code> template tag, but failed to include a <co...
What is theme-compat?
wordpress
I would like to run an add_action in functions.php only if the theme is being loaded from my localhost development site. How would I get this to run only on localhost? <code> function livereload(){ ?&gt; // mycode &lt;?php } add_action('headway_body_close', 'livereload'); </code>
This is the corect answer <code> if ( $_SERVER["SERVER_ADDR"] == '127.0.0.1' ) { function livereload(){ ?&gt; // mycode &lt;?php } add_action('headway_body_close', 'livereload'); } </code>
Functions.php code that only runs on localhost?
wordpress
I have a custom-post-type named <code> wr_events </code> . I have quite a lot of meta-boxes in this post-type. The post-type and the meta-boxes itself work just fine. Only thing: No matter at what post-type I create a "New post" I get quite a lot of php errors and notices … <code> Notice: Undefined index: _wr_event_spe...
Start by reading the notices--they tell you very explicitly what the problem is. Let's start with the first one: <code> Notice: Undefined index: _wr_event_speaker in /Users/my/htdocs/wr/wp-content/themes/wr/functions.php on line 246 </code> First, this is just a "notice". Meaning that no error has actually occurred. PH...
Meta-Boxes for CustomPostType cause PHP Errors and Notices in "Add New" view
wordpress
So currently I have this working for 'search' ie: if I do www.domain.com/search/query, it returns everything it finds on the word 'query'. I would like to utilize that loop/template I created within that search.php but change it to posts. Then query a specific post category if possible ie: www.domain.com/posts/category...
You can customise the loop query to get results based on a search term - with $s being the search term; <code> &lt;?php // Post Query $args=array( 's' =&gt; $s, ); ?&gt; &lt;?php query_posts($args); ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; </code>
Custom loop by url
wordpress
For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and styles" that I enqueued for the front-end were also enqueued in the backend as well. This is how I did it: <code> add_acti...
The "init" action runs both on frontend page loads, and on backend page loads. Try hooking these to the "wp_enqueue_scripts" action instead. I believe it does not run on admin page loads. Example Code: (By OP) <code> function wpse54388_scripts_styles() { wp_enqueue_style( ... ); wp_enqueue_script( ... ); } add_action( ...
Enqueued scripts and styles loading in WordPress Dashboard as well
wordpress
On the default <code> post </code> type, why does the <code> has_archive </code> property equals to <code> FALSE </code> ? <code> $type_obj = get_post_type_object('post'); var_dump($type_obj-&gt;has_archive); // FALSE </code>
Late answer . <code> has_archive </code> applies only for the <code> rewrite </code> arguments. In Detail If <code> has_archive </code> is set to <code> true </code> , then the <code> $archive_slug </code> will get set to the <code> rewrite['slug'] </code> argument. If then a <code> rewrite['with_front'] </code> arg is...
has_archive=false on the default post type
wordpress
I have installed a new Ubuntu server and have set everything up for Wordpress. I have also extracted mySite directory in the /var/www/ and did a <code> mysql -u mysqlusername -p databasename &lt; blog.bak.sql </code> to restore the data to the database. It all worked smooth and works beautifully. The only problem I hav...
This is most likely because of file permissions on your server. WordPress needs to be able to write to the <code> wp-content </code> folder. I highly suggest you read this article about changing file permissions for WordPress. You may also need to CHOWN the directory that contains WordPress to the user that your web se...
Restored Wordpress on new Server - Can't auto-update plugins
wordpress
The code below is my theme options page (submenu - under "Appearance"). All options work fine except "select" and "radio"... They don't appear in the page as the other options do. I have been searching around the internet and trying different solutions for 3 days but there were no ways to make them appear. After that I...
As per my experience isset will not work for text, textarea it will work for checkbox, radio etc (may be someone can guide you in depth for this) To set option with dropdown selection I would prefer to use switch and case as below <code> &lt;?php switch (get_option('your_option_id')) { case "Default": ?&gt; &lt;link re...
Theme Options Page - Select, Radio, Tabs
wordpress
I have successfully created a wp-LINKS-list-table that displays the output of WP's core "Links" table in the WP Dashboard, and I have it displaying on a menu page I created. Step 1 accomplished! But now I would like to be able to have the single row edit/delete (database) functionality just like the Links page. Right n...
Wordpress allows you to use a class called wpdb <code> Here is an example of how you would use it function add_to_db() { global $wpdb; $your_table_name = $wpdb-&gt;prefix . "wp-LINKS-list-table"; $the_value = '123'; $wpdb-&gt;insert( $your_table_name, array('column_name' =&gt; $the_value,)); </code> this will insert 12...
How to edit/delete single row items in a table on my own menu page
wordpress
I'm using the plugin Jigoshop and I'd like to change the wording of the admin menu to something other than "Products": How can I do this? What files need editing?
Update: Read the story.... Person A: Where can I get a helmet for my bike! Person B: 2 block ahead turn right and you will see the helmet shop!!! Unknown: Whoa man... this guy doesn't care about safety.... -1 -1 -1.... Person C: Buy a car fully loaded with air bag and safety features... Unknown: Cool.... +1 +1 +1.........
Change wording of admin menu item?
wordpress
ANSWER MOD : just an important mod to the chosen answer: <code> // check if you actually have drafts; also avoids extra '|' separator if (isset($views['draft'])) { // 'Drafts' should be added (and come first) if you don't want to end up with 'Unavailables' $views['draft'] = str_replace(array('Drafts','Draft'), 'Unavail...
I was investigating the issue for stackexchange-url ("this question"), and one option is using the plugin Edit Flow . It can be configured to display custom <code> post_status </code> in specific CPT's, but further tests are necessary to see if it applies to this case. Other option is using toscho's Retranslate plugin,...
How to change "Draft" string for status of custom post type to "Unavailable"?
wordpress
I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then 'filter'(return with ajax) only the posts that fit the search. I also want it to be paginated. I've found several ways to m...
The original request that loaded the page you are making the AJAX request from ended as soon as the page was sent to your browser. That connection is closed and it is gone from memory. When you make an AJAX request, it's a new request, so <code> $wp_query </code> is empty because you haven't queried anything. You need ...
How to filter a static post page with ajax and $wp_query
wordpress
I want to get url friendly for pass data to page from other page. I explain : I have on i classic wordpress page, url like it : ( example.com/agent/name_agent ) it's url build dynamically. ( get_permalink($id_page_agent) . $name_agent ) In my loop-agent.php , i can manage $_GET['agent_name'] to make a filter. I need to...
Rather then trying implement something for you, I would recommend you to read these two nice articles about Rewrite API: The Rewrite API: The Basics and The Rewrite API: Post Types &amp; Taxonomies . Spare no effort to read these articles and it will help you a lot in a future.
Wordpress redirection to get url friendly
wordpress
It seems like stupid bug, but how can i order by title? It anyways orders by date! I'm using: <code> query_posts( array( 'post_type' =&gt; 'page', 'posts_per_page' =&gt; -1, 'orderby' =&gt; 'title', 'order' =&gt; 'ASC' ) ); </code> I want to use this in function as SHORTCODE. What i'm trying to achieve is to create sit...
Thanks to Chip Bennett who told me that i'm doing wrong by using <code> query_posts </code> inside content. So i used <code> get_posts </code> and i got what i wanted, thanks! Here is sample of how can you do it, if you got the same problem as me: <code> function some_name(){ global $post; $tmp_post = $post; $args = ar...
query_posts doesn't order by title
wordpress
My wordpress website is just moved FTP to FTPS protocol. When I tried to make a connection with FileZilla , the connection is successful. There is nothing wrong with my FTPS connection. <code> Status: Connecting to 88.247.100.147:16666... Response: fzSftp started Command: open "sonergonul@88.247.100.147" 16666 Command:...
In FileZilla you use SFTP connection to access your server and it works (because it was setup on server). But in wp-admin you use FTPS connection, which is probably doesn't setup on server. Pay attention that SFTP != FTPS. A solution could be to change File System method in your <code> wp-config.php </code> file by add...
Wp-Admin FTPS Connection Error unlike Filezilla
wordpress
Here's the problem: I paste the HTML entity code for, let's say, a service mark ( <code> &amp;#8480; </code> ) into the HTML view of the editor. As soon as I switch to the "visual" tab, my entity code is turned into an actual service mark character (I guess the corresponding UTF-8 character or something? I don't know f...
According to this page , you can use the <code> tiny_mce_before_init </code> filter, make sure the entity encoding is set to <code> named </code> , and then add whichever special characters you want to the entities array.
How can I stop TinyMCE from converting my HTML entities to characters?
wordpress
Just created a new self-hosted WordPress blog, and among the very first things, I "unchecked" the <code> Allow link notifications from other blogs (pingbacks and trackbacks) </code> option under Settings > Discussion . I was fixing a few things for the to-be-launched-soon blog, when I noticed a pingback on the default ...
The thing is, the default post has both comments and pingbacks/trackbacks enabled by default. And post or page level settings override the site-wide settings. So, for ONLY the "Hello world!" post (if you are not deleting it), you'll have to specifically uncheck <code> Allow trackbacks and pingbacks on this page. </code...
Disable pingbacks and trackbacks in blog posts
wordpress
What do I need to do to display thumbnail + tags + title of a child page? [ Thumbnail ] [ Title ] [ Tags ] Thanks! EDIT: Well this work, but only showing thumbs+title... it shouldnt be too difficult to add the tags: <code> &lt;?php $child_pages = $wpdb-&gt;get_results("SELECT * FROM $wpdb-&gt;posts WHERE post_parent = ...
Assuming that you've enabled support for both post thumbnails and post tags for static Pages, I would use <code> WP_Query() </code> to build your query, and do something like the following: <code> global $post; $child_pages_query_args = array( 'post_type' =&gt; 'page', 'post_parent' =&gt; $post-&gt;ID, 'orderby' =&gt; ...
How to display thumbnail + tags + title of a child page?
wordpress
This is driving me nuts, and I'm sure that as soon as someone points out the answer, I'm going to feel dumb. I have a website where most pages require login to view. So I am using an if statement to view page content if a user is logged in, or view a login form if not. If I put this in a page template, everything works...
Because you ending php file with : and not putting at the end of header <code> endif; </code> php expects it to finish your IF. In other words - you can not use this in header this way without ending IF. Or you have to create global variable and asign value [lets say true if logged in] to it in header so other php in t...
PHP if statement works in template files, but not header
wordpress
I can't remove a filter that added by media-tags plugin. it was originally added this way: <code> add_filter( 'attachment_fields_to_edit', 'mediatags_show_fields_to_edit', 11, 2 ); </code> I tried to remove it this way: <code> remove_filter( 'attachment_fields_to_edit','mediatags_show_fields_to_edit', 11, 2 ); </code> ...
It depends on the call sequence. Are you sure that the <code> remove_filter </code> is called after the <code> add_filter </code> and before the <code> attachment_fields_to_edit </code> filter is invoked? Add few trace statements and verify.
How to remove this filter?
wordpress
If a plugin modified one of wp's filters by "add_filter", and I want to discard the modification and modify the wp's filter by my own codes. Should I remove the plugin's filter before I add my own filter?
Yes, you need to remove it first and then add your one. You can do it by calling remove_filter function like this: <code> remove_filter( 'wp_core_filter_hook', 'wp_core_filter_hook_handler', 10 ); </code> Pay attention at third parameter passed to function: it is priority, it should be the same as defined when the func...
Should I remove_filter in order to replace a filter?
wordpress
The WP.SE community has always advised the use of <code> wp_register_script </code> and <code> wp_enqueue_script </code> for adding scripts in a theme/template (and likewise, <code> wp_register_style </code> and <code> wp_enqueue_style </code> for stylesheets). This is how I register and enqueue my scripts... First, I ...
<code> WP_Scripts </code> and <code> WP_Styles </code> classes are behind <code> wp_enqueue_script </code> and <code> wp_enqueue_style </code> functions. If you take a look at classes implementation (scripts and styles) then you will see that <code> WP_Scripts </code> class doesn't support any kind of conditional scrip...
Register and enqueue conditional (browser-specific) javascript files?
wordpress
I have seen WordPress developers use two different methods for loading custom widgets from the functions.php file. The first: <code> include("functions/my-custom-widget.php"); </code> The second: <code> require_once(dirname(__FILE__) . "/functions/my-custom-widget.php"); </code> Which one of these methods is more effic...
Both are acceptable but not recommended. Use <code> locate_template() </code> instead because a child theme can overwrite the loaded file then. Example: <code> $found = locate_template( 'functions/my-custom-widget.php', TRUE, TRUE ); </code> The first <code> TRUE </code> tells WordPress not only to search for the file ...
What is the most efficient method for loading widgets in functions.php
wordpress
Do not misunderstood. I am trying to remove/disable Show toolbar option (not talking about hide/disable admin bar) but talking about The Option into Profile Settings. I tried to search but in all I found only how to disable admin bar from front and back but nowhere I found how to remove the check-boxes from profile set...
the fields are hard coded there is nog filter or action to disable it. You could hide it with CSS.... If you want you could replace the entirely page with a different one you custom create.
remove admin bar show hide option from profile settings
wordpress
I need to code a exit popup plugin with jquery . It should be similar as this one http://kbeezie.com/view/cross-browser-exit-pop/ the demonstration is here http://kbeezie.com/exitpop.html Can anyone please help me how to code this so it display on all pages and posts. Any type of help/tip will be appreciated. THanks
Before I give you any code, I want to be very clear that exit popups are frowned upon in pretty much every development community. They're annoying to users, create a bad customer experience, and will tick off just about any developer who ever looks at your site. I can't say this any more emphatically, but please, pleas...
How do i code exit popup plugin?
wordpress
I would like to create two instances of WP on a single domain. For example, I would like wp1.domain.com and wp2.domain.com to use a single database (same comments/posts). One for production and one for development. Is this possible, and if so, how?
It's considered best practice to have two separate databases (one for production, one for development) then migrate the database as detailed here . If you, for example, install a database-changing plugin on one but not the other, you risk breaking one of your sites until you duplicate those changes over. If you're work...
Single database for multiple instances
wordpress
I want to display notification bar on header in my Wordpress theme when user submit certain number of post. I want to notify my author once they are submit amount of post. e.g. if (authorpost === 50){ // congratulations! you have submitted total 50 posts bla bla. } else if (authorpost === 100) { // congratulations! you...
A simple way to achieve this would be to do something like the following; <code> &lt;?php $user_id = get_current_user_id(); $post_count = count_user_posts($user_id); if ($post_count &gt;= 50 &amp;&amp; $post_count &lt; 100) { // Congratulations you have submitted 50 posts! } elseif ($post_count &gt;= 100) { // etc etc....
Display Notification Bar on Header on Certain Post Count
wordpress
I've developed a couple plugins which grab CPT items through a shortcode (via WP_Query). The problem I'm having is that any content entered in the WP Editor before I call the shortcode is run is always output after the shortcode data. Editor: <code> My regular content here [shortcode] more content here </code> Page out...
Your shortcode should return it's output and not echo it out ex: <code> $defaults = apply_filters( 'arconix_faq_shortcode_query_args', array( 'post_type' =&gt; 'faq', 'showposts' =&gt; 'all', 'order' =&gt; 'ASC', 'orderby' =&gt; 'title' ) ); extract( shortcode_atts( $defaults, $atts ) ); /** Translate 'all' to -1 for q...
Content in WP Editor displayed below CPT shortcode
wordpress
On an empty wordpress database, I insert one sample post using the wp_insert_post. Since it's an empty database, the first post I add ends up with id 1. And I check that in the wp_posts, everything looks right ( well for some reason post_name is blank but I do not want to focus on that now ). The question is but when I...
You should insert posts with <code> wp_insert_post </code> and update posts with <code> wp_update_post </code> . <code> wp_update_post </code> will add a revision to the database and update the published/draft post data.
duplicate posts when trying to update a post using the wp_insert_post.
wordpress
When saving a post with the title <code> Jule's Gormet </code> , it gets formatted as <code> Jule&amp;#039;s Gormet </code> . If I save it again, it becomes <code> Jule&amp;amp;#039;s Gormet </code> . Following this pattern, it keeps escaping the ampersand and getting worse. More info WordPress version: 3.3.2 Theme: ht...
EDIT: Disable magic_quotes_gpc in your server. try adding in .HTACCESS file (if you on shared hosting): <code> php_flag magic_quotes_gpc off </code> If you'll get 500 server error after you added it - delete it and put this: <code> ini_set ('magic_quotes_gpc', 0); </code> in theme's functions.php file. And with functio...
How to get my post title to work with an apostrophe ('s)?
wordpress
I know how to mark a Page or Post as visible only to members, using the Member Access plugin. This way, the public cannot view them; instead, you have to log in to see the page. How do I mark a PDF or other Media upload as visible only to members?
Searching this Stack, I can see two possible solutions for this question (not tested). One The answer is not fully developed, but can provide some insight. stackexchange-url ("Restricting access to files within a specific folder") Two stackexchange-url ("How to Protect Uploads, if User is not Logged In?") Frank Bueltge...
How to make media upload private?
wordpress
How can I have analytics which show which registered user saw which page? Is there a plugin that can provide this functionality?
If you use Google Analytics, you can add custom variables to the tracking code to pass a user ID.
Check which user saw which page
wordpress