question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I need to add the following JS to the head, but I don't know how to add the "data-cfasync="false" " by using "wp_register_script" or "wp_enqueue_scripts". Please help!! <code> &lt;script data-cfasync="false" type="text/javascript" src="http://use.typekit.com/YOUR-KIT-ID.js"&gt;&lt;/script&gt; &lt;script data-cfasync="f...
If you need to add it in the <code> head </code> , then this might help you: <code> &lt;?php add_action('wp_head', 'add_attr'); function add_attr(){ ?&gt; &lt;script data-cfasync="false" type="text/javascript" src="http://use.typekit.com/YOUR-KIT-ID.js"&gt;&lt;/script&gt; &lt;script data-cfasync="false" type="text/java...
wp_register_script Question
wordpress
Apparently a lot of people complain that they only see random letters and characters: My biggest problem is that I can't reproduce the problem on ANY of my devices! Not on my Windows XP laptop, not on my Windows 7 laptop, not on my Android phone or my iPod Touch. It doesn't matter which browser I'm using. The only time...
Let’s start with the output we got before the fix: What happened here? My guess: a collision between the plugin W3 Total Cache and your web server LiteSpeed. I found a thread in a Drupal forum about a very similar (or the same) issue. LiteSpeed seems not to send the appropriate HTTP headers for the compressed cache fil...
Page output in strange characters
wordpress
According to a number of references online, I should be able to use the following function to add the class, <code> has-children </code> , to menu items that have children under them: <code> function gtp_nav_menu_css_class( $css_class, $item ) { global $wpdb; $has_children = $wpdb-&gt;get_var("SELECT COUNT(meta_id) FRO...
You can't shouldn't hardcode table names into queries, especially with multisite. Swap <code> $wpdb-&gt;postmeta </code> for <code> wp_postmeta </code> and it'll likely work. edit- technically you can , edited for clarity.
Problem adding 'has-children' class to wp_nav_menu
wordpress
I was just wondering if there is a compelling reason to not let a plugin add columns to a core WordPress database table, such as wp_term_taxonomy. I could always create a separate table and join it to the WordPress core table, but I would prefer to keep the additional data that my plugin uses in the standard WordPress ...
Two Problems Problem #1 - You shouldn't ever change the default schema that ships with WordPress. This schema might change in the future (entire tables could be dropped and re-built in an update). Problem #2 - You shouldn't really be creating new tables in the first place. If you create a new table with your plugin it ...
Adding columns to core tables
wordpress
Is there any specific hook that fires when admin setting is saved. I have cached some data from admin back-end setting menu. Now i want to the delete the caching when setting saved in admin menu. Thanks in advance for help.
There is the filter <code> 'pre_update_option_' . $option </code> . You have to know the option name. Options can be updated from front-end too, so WordPress doesn’t make a difference here. Then there is an action : <code> 'update_option' </code> , you get the arguments <code> $option </code> , <code> $oldvalue </code>...
Hook that fires when admin setting is saved
wordpress
I'm making a plugin that creates user accounts. Is there a way I can create new users that get the role that I (the plugin developer) tell them to, as opposed to making them all the default new user role. I want to make new users a role type that is defined by my plugins parent plugin.
You can use the <code> user_registration </code> action to set a custom role directly after wp_insert_user() has been called. <code> add_action('user_register', 'foo_set_new_user_role', 9999, 1); function foo_set_new_user_role($user_id){ $user = new WP_User( $user_id ); $user-&gt;set_role('your_new_role'); } </code> Yo...
Can a Plugin Override New User Default Role Type
wordpress
I need to query only custom posts types - that is all post types in my WP install excluding posts and pages. I have used <code> get_post_types </code> to build a string of all custom post types which I want to query: <code> $args=array( 'public' =&gt; true, 'exclude_from_search' =&gt; false, '_builtin' =&gt; false ); $...
Instead of creating a string try creating an array and check. <code> $posttypes_array = array(); foreach ($post_types as $post_type ) { $posttypes_array[] = $post_type; } </code> And then form the query as follows <code> $buildArgsAllQuestions = array( // Add out new query parameters 'post_type' =&gt; $posttypes_array,...
Use get_post_types to query only custom posts types
wordpress
I want to hook a function upon activation of a blog in wordpress multisite. I have this, <code> add_filter( 'add_signup_meta', 'custom_add_signup_meta' ); function custom_add_signup_meta ( $blogmeta = array() ) { $the_country = $_POST['country-origin']; $d_currency = $_POST['user_currency']; $d_zone = $_POST['state-ori...
There are two possible causes I can think of: The ' <code> wpmu_activate_blog </code> ' hook supplies 5 arguments ( <code> $blog_id, $user_id, $password, $signup-&gt;title, $meta </code> ), but you're only receiving 2 parameters ( <code> $blog_id, $blogmeta </code> ) The ' <code> wpmu_activate_blog </code> ' hook is on...
Activate blog hook
wordpress
Pretty much all of the content on the site is going to be dynamically generated (php + db backend) What is the preferred "wordpress way" of passing data to a php template (set up as a template in a wordpress theme) So the template would be something like <code> &lt;?php generate_content_based_on_this_variable(page); ?&...
If you want to produce a page in WordPress whose structure and content are dynamically generated independent of the regular posts handling mechanism then: Create a new page with title " My Custom Page ". This generates the page slug ' <code> my-custom-page </code> ' by default. In the root of your active theme folder e...
How do I pass data from page content to the underlying PHP template
wordpress
I have made a custom post type and need to be able to create posts and assign them to authors. It is easy to do this with posts as you can go to the bulk edit screen and immediately change the author. However, when I try to do this with my custom post type the author box is not there. How do I add the functionality to ...
I found out that the edit author attribute is not added by default in for custom post types. To add the author attribute the following code is required: <code> function allowAuthorEditing() { add_post_type_support( 'mytype', 'author' ); } add_action('init','allowAuthorEditing'); </code>
How do I change the author of a custom post type?
wordpress
we're working on a bilingual site, Larry A. Downs all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories, i've coded out a shortcode that sets up a tabbed widget in the sidebar, based on the language category, using multiple WP_Query's a...
As of WordPress 3.6 you can put comma-delimited entries in the category_name property of the arguments array like this: <code> $args = array( 'category_name' =&gt; 'news2014,news2015', ); query_posts($args); </code> This works if the categories are both at the root level (no parent)
shortcode using multiple WP_Query's with multiple category names not fully functional
wordpress
I'm trying to create a custom url rewrite for my wordpress plugin. <code> function insert_plugin_rewrite_rule($rules) { global $wp, $wp_rewrite; $wp-&gt;add_query_var('update_slug'); $ret = $wp_rewrite-&gt;add_rule('updates/plugins/([^/]+)/', 'index.php?update_slug=$matches[1]', 'top'); // Remove when debugging is done...
first, you should use the proper filter and method to add query vars and rewrite rules and not manipulate the globals directly. the other issue I believe is your regex pattern, this is working for me: <code> add_filter( 'query_vars', 'wpa59404_query_vars' ); function wpa59404_query_vars($query_vars){ $query_vars[] = 'u...
Wordpress URL Rewrite not working
wordpress
I have portfolio-post-type.php which contains this: <code> &lt;?php add_action( 'init', 'create_portfolio_post_type' ); function create_portfolio_post_type() { register_post_type( 'portfolio', array( 'labels' =&gt; array( 'name' =&gt; _x( 'Portfolio', 'post type general name', 'flowthemes' ), 'singular_name' =&gt; __( ...
Just add this code under your category registration. Check the <code> register_taxonomy() </code> function for more details. Usually when you set <code> hierarchical =&gt; true </code> taxonomy looks like category and <code> hierarchical =&gt; false </code> its looks like tag. <code> register_taxonomy('portfolio_tag','...
portfolio custom type tags support
wordpress
I try to create a theme. In that theme I have create a custom post type and I quering the WordPress by using the wp_query to get the posts from that post type with the code that following : <code> $args = array( 'post_type' =&gt; 'portfolio', 'posts_per_page' =&gt; 18 ); $projects = new WP_Query($args); while($projects...
Use <code> get_the_date() </code> instead, here's note from <code> the_date() </code> codex page regarding the issue: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts publi...
WordPress | Date not always appear
wordpress
I have a custom post type and need to display it in a certain way. I would like other posts to display as normal. When I tried to use the following code to accomplish this, I get a 500 Internal Server Error. <code> global $post; //do this only for custom type if (!(get_post_type()=='customt')) { $rawContent = $post-&gt...
Please try to replace your snippet with the following. The <code> global $post </code> isn't needed, when it's outside a function or method context and inside the loop, as then <code> $post </code> is already <code> global </code> and <code> get_post_type() </code> s default <code> false </code> arg with be replaced wi...
Apply Filters Causing a 500 Internal Server Error
wordpress
Ho do you remove admin menu items and dissable acces for users below admin ? The right way... <code> // 1 - Remove Menu Items function my_remove_menu_pages() { if ( !current_user_can( 'administrator' ) ) { remove_menu_page('options-general.php'); // Settings remove_menu_page('tools.php'); // Tools remove_menu_page('upl...
There are three ways to do this I guess. First, you could start with blocking all access to admin.php and then whitelist the pages they are allowed to browse. Unless your users are really restricted this may take a while to figure out. Second, you could use the built-in capability system of WP, removing capabilities of...
Remove admin menu
wordpress
Does anyone know how to enqueue the script "Jquery UI Tabs" in admin area? I want to use it inside my theme options page. Already read the related wordpress documentation but with no results... I have added UI Tabs to the front-end and works fine but I cant add it in the admin area... Thanks in advance.
I normally load it as a dependancy of my plugin's js file like so: <code> if ( is_admin() ) { //load my plugin's js add_action('admin_print_scripts', 'my_plugin_load_js' ); } function my_plugin_load_js() { $plugin_js = WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/my-plugin.js'; wp_enqueue_script('my-p...
Enqueue jQuery UI Tabs In Admin Area
wordpress
I am trying to figure out what is going to be my best route to go in this choice. I have a Unity game I have integrated with Wordpress but I need to send and receive the high scores of the game in the WP database. Should I create my own table in WP to store my high scores along with the user information of people who h...
I'd use a custom table for this. Otherwise you'd have to have a lot of custom post types posts containing very little information. Your own table is easier to manipulate (and, god forbid, export should you want to use another high score solution).
Wordpress and Unity high scores table
wordpress
I wanted to add an action on when a user activated the blog through standard signup process, all my custom meta on the registration will be inserted on my modified <code> wp_blogs </code> table. Here is my code for the custom signup meta. <code> add_filter( 'add_signup_meta', 'custom_add_signup_meta' ); function custom...
I think this is what you're looking for: <code> add_action('wpmu_new_blog', 'insert_custom_datas1', 10, 6); function insert_custom_datas1($blog_id, $user_id, $domain, $path, $site_id, $blogmeta) { // Your code here } </code> Let us know how it goes?
WP Multisite: Do a function after blog is activated
wordpress
I am making a Top Photos section in a page. This section will have 3 last post (there are galleries in the posts), each with thumbnail, link and excerpt from the posts. The posts will be displayed in "box-style" and align horizontally. Container for these boxes is 1050px wide. Here is my loop: <code> &lt;div id="top-co...
They key is here: <code> &lt;li &lt;?php post_class(); ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt; </code> You can add a parameter to the <code> post_class </code> call, e.g.: <code> $counter = 0; $custom_query = new WP_Query('cat=2687&amp;posts_per_page=3'); //Top of the page - Top Photo Category while($custom_query-...
Targeting a Certain Post in Loop (CSS)
wordpress
I know all the downsides of trying to include wp-load.php, but bear with me :) I'm trying to create my own admin-ajax-like functionality, in a way that I can control whether or not I load the default WordPress environment, whether I load it with the <code> SHORTINIT </code> constant defined as true, and with granular c...
Well, it turns out it was a problem of variable scope. I discovered that <code> $wpdb </code> was loading fine, but was inaccessible outside of the function that generated it, so it kind of led me to the solution: the <code> includes() </code> I mention in the question are done inside a function, with local (not global...
Including 'wp-load.php' after another include() generates an error
wordpress
Is there any reason to use admin-ajax.php for ajax requests versus a custom page template? I didn't know about admin-ajax.php until recently, so what I had been doing is creating a custom page template like this: <code> &lt;?php /** * Template Name: API */ if ( isset( $_GET['ajax_request'] ) ) { // do stuff } </code> A...
First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink structure to all work correctly. Using <code> admin-ajax.php </code> will work correctly in any context, theme or plugin, where proper WordPress best practices are followed. The less obvious drawback to the...
admin-ajax.php vs Custom Page Template for Ajax Requests
wordpress
is there an option or a plugin that resizes an image depending on it's orientation? Reason for this question: Im building an image grid and it would look even better when all images would have the same width.
If you need the images to be the same width but varying heights (ie not 300 x 300 but 300 x anything) then in settings -> media add 9999 to the height of whichever image size you want to use. You can also define your own custom thumbnail using the same principle: http://codex.wordpress.org/Function_Reference/add_image_...
Image resize depending on orientation?
wordpress
I am making a theme and it has so many options that need to be updated via jquery's ajax.Having looked at ways of updating wp_options via ajax,i have hypothesised that updating the wp_options table would be the easy way out for me. Are there risks if update the options that way or is it safer to go the api way?.
Updating options via pure SQL is wrong. If you feel you have too many options to use the regular API you probably have too many options at all. A theme should not do the job a plugin can do. In fact, it should do as little as possible and let the user choose a plugin for simple tasks. Examples are fields for tracking c...
Are there risks associated with using wp_options table using wpdb to update theme options
wordpress
I am testing a very big database (perhaps <code> wp_posts </code> contains hundreds of thousands of rows). As such, the query time, especially the searching query, is extremely long. I'm thinking if there is any other way to split the WP database to multiple tables with different table prefix so that the url structure ...
Pam, It sounds like you are facing some major challenges, but I would highly recommend not messing with the table prefix. Doing so will lead to a series of problems, which will require hack after hack to remedy leaving you with a substantial mess of a WordPress installation. There are some other things you can do to he...
How to use if condition to change $table_prefix in wp_config.php
wordpress
I'm trying to develop a WP plugin to show post(or page) related information (such as show all post title in a list) in an admin menu page. I tried to use "The Loop", but it seems like "The Loop" cannot be accessed in Dashboard. I have achieved my goal by using $wpdb to query database directly. But is there a better or ...
It was my mistake, the loop can be accessed in the admin panel
How to dispaly post informations (such as titles) in an admin plugin menu page?
wordpress
I have this url to call the taxonomy.php by pressing the button with the code beneath to show filtered posts: <code> http://myurl/?meta_key=post_views_count&amp;orderby=meta_value&amp;order=ASC </code> This is the JS I am using: <code> $(document).ready(function(){ $.ajaxSetup({cache:false}); $("#hot a").click(function...
Try this code in your <code> complete </code> callback of the <code> load </code> function: <code> $(".postbox_wrapper").load( jQuery(this).attr("href") + " .postbox_wrapper", function(response, status, xhr) { // complete callback // create a empty div var div = document.createElement('div'); // fill div with response ...
url - ajax loaded but no JS
wordpress
i want to rename TAG to TOPIC and url it should be wordpress.stackexchange.com/tag/ to wordpress.stackexchange.com/topic/ is it possible ?
Click on the image to enlarge. The screenshot shows the Permalinks settings screen. To do what you want, specify topic in the Tag base field/box.
How to rename 'TAG' to 'TOPIC'
wordpress
I am trying to create posts in hindi language. These characters <code> UÉeÉMÑüqÉÉU </code> after saving/publishing are interpreted as <code> U�e�M��q��U </code> . Though, the special characters are stored with no change in the mysql database. The <code> � </code> symbol is only during retrieving. I'm stuck here. The po...
Its utf-8 character encoding problem. Fixed it using the function utf8_encode(): <code> utf8_encode(html_entity_decode($mb-&gt;get_the_value())); </code>
special characters after saving draft interpreted as �
wordpress
Installing Wordpress SEO (an a few others but not all plugins) gives the following console error: GET http://craigmdennis.com/content/plugins/nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/wordpress-seo/js/wp-seo-admin-global.js?ver=1.2.5 404 (Not Found) For some reason it is listing the complete ...
The error is the result of the php <code> __FILE__ </code> resolving any aliases or symlinks on the server. The solution is to set <code> define('WP_CONTENT_DIR', dirname(__FILE__) . '/content'); </code> so it is also the absolute file path on the server after resolving aliases. See: http://php.net/manual/en/language.c...
Some plugins adding full server path after url (with custom wp-content folder)
wordpress
Basically, I have a custom tinymce button which opens a thickbox window in iframe mode. Is there a way to access the tinymce from the iframe? Wordpress media uploader seems to do it somehow. Stuff like <code> $('#content', window.parent.document).tinymce().getContent() </code> does not work. Wordpress 3.4.1 Thank you! ...
tinyMCE isn't implemented as a jQuery plugin. I'm not sure, but this would be more probable: <code> window.parent.tinyMCE.get('editor').getContent() </code>
Access tinymce from thickbox
wordpress
As it is now, when a page that is in the nav menu is trashed, it still stays in the menu until manually remove via the nav menu editor. Is it possible to have trashed pages removed automatically? Thanks
Just hook the default <code> delete_post </code> handler for menus onto the trash action too: <code> add_action( 'wp_trash_post', '_wp_delete_post_menu_item' ); </code> How simple is that!
Automatically remove trashed pages from nav menu
wordpress
(This is my first time posting here, so would appreciate if anyone could let me know the best way to post questions). Until now, I had been using TwentyEleven Theme and adding "Options Framework - http://wptheming.com/options-framework-theme/ ". It works great and I wish to continue using it. However I found a better b...
Unless Options Framework has some gnarly features that knock Hybrid out the water, I would simply... move on ;) Taking the time to learn a new framework beats the hell out of the idea of merging &amp; then maintaining two - I just think it'd cause more headaches in the long run than it might solve at the beginning.
Is it good idea to combine Options FrameWork with Hybrid Core Framework
wordpress
I think it's great to use conditional tags but if the query is slightly advanced it won't give information about the original query. For example; is_category('apple') might give a false response if "banana" AND "apple" has been queried. This is because is_category() compares against one single category and doesn't both...
is_category('apple') might give a false response if "banana" AND "apple" has been queried you're using <code> is_category </code> incorrectly in this context. From Codex: is_category(); // When any Category archive page is being displayed. A category archive page is for a single term, if a query is a for more than one ...
For what queries is conditional tags informative?
wordpress
I'm trying to change the options that are presented for the gallery settings. I can't seem to find a hook or override that gets exactly what I want. I came close with the following, but it only seems to add to the top of the tab. <code> function media_upload_gallery(){ echo 'test'; } add_filter('media_upload_gallery', ...
There is no way to alter the gallery settings. About the only thing you can do is to override the entire gallery shortcode. You can technically have your users pass any sort of parameters into the shortcode and recognize them with your alternate gallery. Simply use: <code> add_filter('post_gallery', 'foo_override_galle...
Is it possible to override the default Gallery Settings form?
wordpress
In a theme I have a form that I need posted and some work done on the server. What is the recommended way of doing this? I have it posting to another php file where some work will be done, and then redirected back to the previous url. I'm having some issues with this because all the functions that normally work in a pa...
I recommend you take a look at the AJAX in Plugins page which should solve your woes with redirects. http://codex.wordpress.org/AJAX_in_Plugins You can send whatever you want to be processed asynchronously. This is a pretty standard way of processing forms in WordPress both on the front-end and back-end. If you need to...
Best Practice for Server Processing
wordpress
I have registered a custom post type <code> 'featured_post' </code> . I am looking for a way to test if the blog home page has any <code> 'featured_post' </code> posts on it and if it has load a javascript file. The 'featured_post' posts will make a slider at the top of the blog home page. I had this working using stic...
I'm at work at the moment (sorry boss), so I can't test this, but the snippet below should be the proper way of testing if the 'featured_post' post type exists, and then enqueue the script if it has any posts. <code> if ( is_front_page() &amp;&amp; post_type_exists('featured_post') ) { // We are at the front page, and ...
if custom posts type exists and there are posts load script
wordpress
Where should a plugin ideally hook to call <code> register_sidebar(); </code> ? Will <code> init </code> do just fine? <code> function my_plugin_register_sidebars() { $args = array( 'name' =&gt; 'foo' 'description' =&gt; 'bar' ... ); register_sidebar( $args ); } add_action( '**????**', 'my_plugin_register_sidebar' ); <...
Twenty Eleven and Twenty Twelve use the <code> widgets_init </code> action. Given that these themes are generally considered to use best practices for theme development, I think this hook would be ideal.
What are ideal hooks to call register_sidebars?
wordpress
I have a CPT called adverts and it has 2 taxonomies - category and location. The problem is that there are about 100 entries in location taxonomy and I need to copy the same structure to another CPT - businesses. Doing everything manually will take forever. Are there any solutions for that? P.S. Taxonomy structure incl...
When you register the taxonomies you can specify multiple post types: <code> function register_my_taxonomies() { register_taxonomy( 'location', array('post','page', 'adverts', 'businesses'), </code>
Copying over taxonomy structure from one CPT to another
wordpress
wp_create_category() adds new categories to the 'content' taxonomy associated with the post type... Simple question really neither wp_create_category() or wp_insert_category() allows configuration for taxonomy type... so how can I can do it?
For custom taxonomies you should use wp_insert_term()
programmatically adding categories to custom taxonomy
wordpress
So I uploaded a lot of similar looking photos, and uploaded a duplicate or two. I go into the backend to the Media panel, but alas, each row has a small thumbnail, making it time consuming to figure out which ones are the duplicates, or just to tell them apart. How would I make the image bigger? At the moment it is 60x...
I don't see any way of hooking into this. Following the lead of <code> wp_get_attachment_image </code> takes nowhere... <code> // wp-admin/includes/class-wp-media-list-table.php // line 200 case 'icon': $attributes = 'class="column-icon media-icon"' . $style; ?&gt; &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;?php if ...
Making the thumbnails in the backend Media section bigger
wordpress
What I'm trying to do is add a body class based on whether there is a post thumbnail. The following works, but I get a PHP Notice. How can I fix the PHP Notice below? <code> function add_featured_image_body_class( $classes ) { if( has_post_thumbnail() ) { $classes[] = 'has-featured-image'; } return $classes; } add_filt...
Try this code: <code> function add_featured_image_body_class( $classes ) { global $post; if ( isset ( $post-&gt;ID ) &amp;&amp; get_the_post_thumbnail($post-&gt;ID)) { $classes[] = 'has-featured-image'; } return $classes; } add_filter( 'body_class', 'add_featured_image_body_class' ); </code>
Add body class based on existance of post thumbnail. Code works but receiving PHP Notice
wordpress
I have a few categories with the same name [some of them are sub-categories]. And I want to get an array of ID's for certain cattegory name. I tried this: <code> $term = get_term_by('name', $cat_name, 'category'); </code> but it seems that <code> get_term_by() </code> returns only the first term that match the query.
The only alternative I know of (using core functions) is: <code> // Get terms whose name begins with "my_name" get_terms( 'category', array( 'name__like' =&gt; 'my_name' ) ); // Get terms whose name contains "my_name" get_terms( 'category', array( 'search' =&gt; 'my_name' ) ); </code> If you need an exact match, you'll...
How can I get category ID by category name?
wordpress
When making an AJAX request is works when my data is a URL style string. <code> var options = { type: 'post', data: 'action=my_action' }; </code> The function will get called and return some fake data just fine. If I try to make the same call but use JSON, it doesn't work. I've tried several different ways of doing it,...
Firstly, <code> stringify </code> won't build a URL query - it serializes it into JSON object notation. And secondly, you don't even need to build the URL query - if you're using jQuery to make the AJAX call, just pass the JSON object as it is - <code> jQuery.param() </code> will internally handle it :)
AJAX call fails when sending JSON but works with URL style string
wordpress
Setting up a multisite on a blog which root url is dev.domain.com, using subdomains. So, for example, a subsites address : site1.dev.domain.com Everything works fine as long as i stay on the main site (dev.domain.com) When i try to access any of the other sites, I get a 404 error. Here is my .htaccess sitting in the ro...
You must also register the wildcard domain *.dev.domain.com (The asterisk in as the sub-domain will usually allow you to create any sub domain you want and it will work) and point it to your main site. You can normally do this through you host's Control Panel. I didn't do this when I started with WPMU and this is what ...
Multisite - 404 when accessing sub-sites
wordpress
Normally when you get a Youtube feed, it will display the description/title from the YT video. However, I want a post to be generated when a new video is posted on YT so that an admin/editor can go back and change the title or add a teaser.
If working with wp_insert_post and the youtube api is too much work, or too complicated, you may be interested in the plugin called "Automatic Youtube Video Posts" (AYVP). It has been working quite well for us. There are some bugs (nothing critical) and it is not the most efficient plugin, but it does exactly what you ...
Generate a WP post from Youtube Feed
wordpress
I use woocommerce plugin for my shop. I want to skip the checkout page where users give shipping details. So the system will be when they select a product and after go to the cart page they will go to paypal and from paypal we will get the adress. Any idea how i can build this, Please help me. I am newbie.
there is an option in the Woocommerce to not include shipping Go to Woocommerce > Settings> Shipping and disable the options there
How to skip woocommerce checkout out page?
wordpress
on my development wordpress server (using Desktop Server's "ServerPress"), one my pages has a list of pdfs; each tag has this path: /wp-content/themes/accessgroup/docs/thePDF.pdf. When I upload my installation to my production server, and I click on one of these links to view a pdf, I get Wordpress's default 404 page. ...
Thanks to @BrianFegter comment, I was able to find and fix the problem. It was just a problem of case-sensitivity. My development environment, http://serverpress.com/products/desktopserver/ , doesn't have a problem with finding the pdf when the file name was caps and the anchor tag link was in lower case. My hosting pr...
Path in dev server works; same path in prod server is broken
wordpress
I want to create something similar to what buddypress does with member pages. For eg; http://www.example.com/members/foo http://www.example.com/members/bar etc. I tried looking up the buddypress code and I see that they don't use custom post type or a custom taxonomy. It also doesn't look like they are using add_rewrit...
Here is the answer. And for future references, Deepak, you need to actually post the solution as an answer. Instead, you posted your answer within your own question and then made a comment about it. Please don't do that. <code> add_filter( 'query_vars', 'analytics_rewrite_add_var' ); function analytics_rewrite_add_var(...
How do I create a dynamic page?
wordpress
I am new in WordPress i am rails programmer that need to do for small Business only WordPress website with : main page, about us, contact + few articles(posts) that will be in the main page "about us", " contact" sections should be article(post) or page in the simple small Business website? Thanks,
It's totally up to you to decide to put it as a post or a page. I would put it as a page though. One important difference between them is that Pages are hierarchycal and Posts chronological. You can study each in the Codex to better decide: http://codex.wordpress.org/Posts http://codex.wordpress.org/Pages This can also...
"about us", " contact" sections should be article(post) or page in the simple small Business website?
wordpress
I have been trying to rename my images on upload and only piece of code I found was the one that uses a 32char hash. <code> function make_filename_hash($filename) { $info = pathinfo($filename); $ext = empty($info['extension']) ? '' : '.' . $info['extension']; $name = basename($filename, $ext); return md5($name) . $ext;...
no need to use a custom table, use an option, and the <code> add_attachment </code> hook: <code> function wpa59168_rename_attachment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); $count = get_option( 'wpa59168_counter', 1 ); // change to $new_name = $count...
Rename files on upload
wordpress
Evening, I'm getting some incorrect links generated by my theme. <code> WordPress Address (URL): http://localhost/newgameplus/wordpress </code> <code> Site Address (URL): http://localhost/newgameplus </code> Clicking on something like <code> preview post </code> Generates a URL like this: <code> http://localhost/newgam...
Site Address (URL) Enter the address you want people to type in their browser to reach your WordPress site. This is the directory where WordPress's main index.php file is installed. The Site address (URL) is identical to the WordPress address (URL) (above) unless you are giving WordPress its own directory. WordPress wi...
Generated URLs don't reflect accurate URLs.
wordpress
I've got a somewhat unique scenario that I would appreciate some assistance with. I have a custom post type, coin, for content that is automatically created by an custom import process. I would like to restrict all users from performing certain actions on any coin posts. Specifically, I want to prevent any user from de...
There's not a good way to do this as the code for this section is pretty rigid. You can simply remove the elements via JavaScript. By removing (and not just hiding) the elements, you disable the functionality. You can customize the following to your needs I'm sure. Use CSS to hide the post actions inner box so the proh...
Custom post type capabilities
wordpress
I am currently working on a major update to one of my WordPress plugins. The plugin lets the user choose from several available skins. Quite often I get asked to create a custom skin. To prevent this skin from being deleted on upgrade I have to use a WordPress hook to disable automatic updates for the plugin. This is o...
Many plugins use <code> /wp-content/custom-plugin-folder/ </code> to store customized plugin data (WPTouch comes to mind). Just use the constants <code> WP_CONTENT_URL </code> and <code> WP_CONTENT_DIR </code> Docs to check for the existence of your folder and retrieve any available skins. The following article, althou...
How to customize a plugin whilst maintaining ability to upgrade
wordpress
I am creating an option page for one of my wordpress themes and I am trying to ask user to enter "Number of posts to show" - I am using "query_posts" to show posts This is the code I modified but it is not working <code> &lt;?php query_posts("posts_per_page='".of_get_option('numberofposts', '3' )."'&amp;cat='".of_get_o...
You have the value of posts per page in single quotes, remove the quotes and it will work. That said, you should be altering the main query with <code> pre_get_posts </code> instead of <code> query_posts </code> .
Echo a numerical value in query_posts
wordpress
I'm working to create a front end custom post type submission from. I already coded checking different tuto. But the form returned not found page upon suvmission, again not inputing any data. Please help me to find out the error if possible. <code> &lt;?php if (!isset($_POST['submit'])) { ?&gt; &lt;form method="post" a...
Since the meta data field is already there you should update it. also you should time the wp_insert_post... here is the revied code try it and let me know it you encounter problems: <code> else { $title = $_POST['post_title']; $meta_box1 = $_POST['wpcf-mob_no']; $meta_box2 = $_POST['wpcf-mob_amount']; $meta_box3 = $_PO...
Front End submission with meta key
wordpress
This is a really bizarre problem. For some reason Chrome does not have any RSS feed formatting? Where as most other browsers do! So it seems from I read online that I have to create my own style sheet for it :/ That's fine, but how can I add my RSS stylesheet to my wordpress RSS feed without manipulating the core files...
I'm not sure this is a problem you really need to solve. Any regular Chrome user knows this is how Chrome (doesn't) handle RSS. That said, you can provide a custom feed template. see Customizing Your Feeds in Codex.
RSS Feed has no styles in chrome - function to add one?
wordpress
I'm looking for a plugin that would allow me to create private groups for discussion that are invite only. These would be for people who have taken a workshop and want to remain in communication with their cohort afterwards. They would need to be invited/added by admin after each workshop and would not communicate with...
You can easily create private forums with the Simple:Press forum plugin. http://simple-press.com/ It can do a LOT more than just that, and for that reason might be overkill (not sure what other requirements you have), but if you are looking for a very flexible and powerful forum system, then I can recommend Simple:Pres...
Forum plugin that allows private groups that are invite only
wordpress
I don't know if i can explain this.. I want to create a Page where the comments of specific user is listed. like this format... User Name <code> Post Tilte - comment - comment - comment Post Tilte - comment - comment - comment </code> well, im not looking exactly as that format, but I want something similar to that. I ...
You can use the get_comments function to retrieve comments from a specific user. <code> $comments = get_comments( array( 'user_id' =&gt; 1 ) ); foreach( $comments as $comment ) { $post_id = $comment-&gt;comment_post_ID; $post = get_post( $post_id ); setup_postdata( $post ); echo '&lt;a href="' . get_permalink() . '"&gt...
Display comments of users on single page
wordpress
I want to know the total number of posts from the category/tag/author/search result that I am actually seeing. Say for example I am in the main page. If my posts_per_page are 10 and my pagination shows 6 pages, that would mean there are a number of posts in my query between 51 and 60. How could I get that exact number?...
<code> &lt;!-- displays total number of posts for query, ignoring pagination --&gt; &lt;?php echo $wp_query-&gt;found_posts ?&gt; </code>
Total number of posts in query (category/tag/author/search results/main page...)
wordpress
I want to show the 3 most recent comments and have a small div underneath that shows how many replies each comment has (count how many comments where comment_parent => comment_ID). I do this by looping through each parent comment (comment_parent => 0) and then for each parent comment, use get_comments(comment_parent =>...
In the wordpress codex function reference for comments , it looks like the parameter for the parent is not <code> comment_parent </code> but just <code> parent </code> . Which is weird and inconsistent because the return values are prefixed with <code> comment_ </code> .
Display number of comment replies
wordpress
I have a CPT called 'vacancies' here is the code that registers it: <code> function register_cpt_vacancy() { $args = array('labels' =&gt; $labels, 'hierarchical' =&gt; false, 'supports' =&gt; array('title', 'editor', 'excerpt', 'thumbnail', 'revisions'), 'taxonomies' =&gt; array('departments'), 'public' =&gt; true, 'sh...
On the wp_list_pages docs , it states that: If a given custom post type is hierarchical in nature, then wp_list_pages() can be used to list the member of that custom post type. Based on your code, the CPT that you are attempting to use with wp_list_pages() is not hierarchical. Therefore, two solutions: 1. Change the Cu...
wp_list_pages not showing cpt as I expected
wordpress
I am looking for a way to override the currently selected theme, preferably from within the wp_config.php file. I know you can override some wp_options settings in the config like <code> define('WP_HOME', 'http://someotherdomain.com'); </code> This will override the 'home' option in the wp_options table. There is an op...
Drop this in a plugin &amp; activate. I should note this doesn't take into account things like child themes - it's purely for toggling which theme renders based on <code> SOME_FLAG </code> . <code> add_filter( 'stylesheet', 'switch_ma_theme' ); add_filter( 'template', 'switch_ma_theme' ); function switch_ma_theme() { /...
Override Current Theme Setting in wp_config.php
wordpress
I have this code in my category.php file <code> &lt;?php query_posts( array('post_type'=&gt;'featured' )); $featured = new WP_Query( array('posts_per_page'=&gt;1, 'tax_query'=&gt; array( array( 'taxonomy' =&gt; 'category', 'field' =&gt; 'slug', 'terms' =&gt; 'fever' ) ))); while ( $featured-&gt;have_posts()) : $feature...
Try using get_queried_object(): <code> $term = get_queried_object(); echo $term-&gt;name; </code> If you get nothing there, try this: <code> print_r($wp_query); </code> Everything you need is in the $wp_query global. Hope this helps you.
reference the current category being used in the category.php page
wordpress
I'm currently using this to add post meta <code> add_post_meta($post_id, 'when', $date); </code> Naturally, it creates a new meta key/value combination each time. I want to another value to the key, so that when date is submitted again, there are now TWO dates in the "when" meta key? Would I then be able to query these...
Use the following instead of add_post_meta: <code> update_post_meta($post_id, 'when' $date); </code> <code> add_post_meta </code> does just that, adds a new meta key every time, including duplicates in your case. <code> update_post_meta </code> also incorporates <code> add_post_meta </code> if a key doesn't exist, but ...
Adding new value to existing meta key
wordpress
I have a slider in my theme. I have a setting in the options which controls whether that slider is set to "slide" or "fade". This slide/fade setting is in the jquery and of course the options setting is in the database. I presume the normal method of getting this setting is via AJAX but I thought I'd ask as I have a nu...
Enqueue the script as you would normally, &amp; then call the JS function right after the slider HTML output (or on <code> wp_footer </code> ), and pass a JSON config back to the function. <code> &lt;!-- slider HTML --&gt; &lt;script type="text/javascript"&gt; jQuery( "#my_slide" ).mySlider( &lt;?php echo json_encode( ...
Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
wordpress
I want the user to be able to set a text, option values or other type of data in each product just before they add it to the cart. Just like product options. For example: The user buys a sticker and is able to set the text to be print I can't use product variations for this task before it is not about fixed values. Is ...
You can use WPEC Personalize plugin from here http://www.derekweathersbee.com/products/wpec-personalize It should do your job.
Custom product fields in wp e-Commerce plugin
wordpress
I'm trying to put the WP Pluploader into a meta box on my posts page - as per stackexchange-url ("Plupload Intergration in a meta-box?") and http://www.krishnakantsharma.com/2012/01/image-uploads-on-wordpress-admin-screens-using-jquery-and-new-plupload/ I got it all working as in the example in the second link. However...
Aha, the problem as that I was calling the <code> wp_ajax_plupload_action </code> from within my page conditional check like so: <code> function __construct() { global $pagenow; $pages = array('post.php', 'post-new.php'); if (in_array($pagenow, $pages)) : add_action('add_meta_boxes', array($this, 'dhf_video_meta_box'))...
Plupload in metabox - AJAX action not working in Class
wordpress
I'm trying to make a plugin which would run either by itself at a specific time or when it is triggered manually(that is, a particular function of the plugin is triggered). I'm not understanding how to implement that though and googling around hasn't been fruitful. If that may help, this is briefly how the function loo...
You can run scheduled events using wp_cron . To trigger it manually you'll need to create an admin screen and create a button that triggers the function. To do that read up on Creating a Plugin and Adding Admin Menus .
How to make custom plugin run on demand?
wordpress
I am wondering if it is possible to create other Widget Holding sections like Active Widgets and Inactive Widgets. For instance, perhaps I would create a Media Widgets section and place all media related widgets in there. Is this possible? If so, how could I create the section and how would I place the widgets in there...
Probably isn't considered "best practices" but it gets the job done. Here's what I did: In my wp-admin/widgets.php, After these lines, <code> // register the inactive_widgets area as sidebar register_sidebar(array( 'name' =&gt; __('Inactive Widgets'), 'id' =&gt; 'wp_inactive_widgets', 'class' =&gt; 'inactive-sidebar', ...
Create More Widget Holders Like Active Widgets and Inactive Widgets
wordpress
I have a theme that automatically adds some widgets. I don't want them and so I tried to edit the Sidebar.php but it just fails and sends me to a page with message 404. Here's the code block I am trying to delete from Sidebar.php: <code> &lt;!-- sidebar south START --&gt; &lt;div id="southsidebar" class="sidebar"&gt; &...
Those widgets are added because you've specified none Try adding a text widget with no content but spaces, you'll find all those hardcoded default 'widgets' dissappear You should never use the built in editor in WordPress though, so use FTP/Shell/VCS instead
Cannot update a file for my theme
wordpress
i having trouble while i added query to loop. please have a look whats the problem. here is the link <code> &lt;div class="fl" id="main_article"&gt; &lt;?php $count = 1; $the_query = new WP_Query( 'category_name=headline&amp;orderby=post_date&amp;order=desc' ); if ( $the_query-&gt;have_posts() ) : while (have_posts()) ...
no idea what the problems actually are, but from looking at the code, I woud suggest: a: the <code> while (have_posts()) : </code> should be <code> while ($the_query-&gt;have_posts()) : </code> b: you would need to increment the counter: <code> &lt;?php $count = $count + 1; ?&gt; </code> c: the <code> endif; </code> of...
Query post & loop problem.
wordpress
I'm currently authoring the development of a plugin for wordpress, and I'm having trouble figuring out which would be the best way to add scripts to the plugin. I'm in the process of adding more scripts, and I already have JQuery (through WordPress), JQuery UI (through googleapis). Eventually I'll be adding SWFUpload, ...
Always use the built-in versions. Don’t waste time with old WordPress installations – other plugins will break there too. See <code> wp-includes/script-loader.php </code> for the list of available files. Quite a lot. :) And avoid remote resources. Some (Google) fail to send the scripts gzip compressed to all supporting...
Which method is best to enqueue scripts
wordpress
I want to make a search page, offering search functionalities by: 1) word 2) tag 3) category 4) author Can you recommend any technique, any guideline as per how to tackle this?
You'll want to add some radio buttons inside your search form. Then add a filter to your search: <code> function filter_search( $query ) { if( $query-&gt;is_search ) { if ( isset($_GET['tag']) ) // alter your search query here. } return $query; } add_filter( 'pre_get_posts' , 'filter_search' ); </code> Influenced by ht...
Search by word, category, tag, author
wordpress
Is there any way to add the <code> .html </code> extension to custom post types without plugin ? For posts I can use <code> /%postname.html </code> on the permalink settings For pages I can use: <code> add_action('init', 'change_page_permalink', -1); function change_page_permalink() { global $wp_rewrite; if ( strstr($w...
This seem to work: Create the rewrite rules like <code> post-type/post-name.html </code> . You can use arrays to create the rules for just some set of post types instead of doing it for all of them. <code> add_action( 'rewrite_rules_array', 'rewrite_rules' ); function rewrite_rules( $rules ) { $new_rules = array(); for...
Add .html (dot HTML) extension to custom post types
wordpress
I'm using custom post type. I want to show every post's the most child category on archive page in wp_query loop. But the_category(''); doesn't work. What should I do? I need your help. Sorry for my bad English. Thanks in advance. My codes: archive-fotograf.php <code> &lt;?php /** * Displays the Pagination in Custom lo...
<code> the_category() </code> only works for the "Category" taxonomy which doesn't appear to be hooked to your custom post type. I see you're registering a custom taxonomy. If you want to show the terms from that taxonomy that are assigned to the post, you'll need to use <code> the_terms() </code> or <code> get_the_ter...
the_category() doesn't working in wp_query loop
wordpress
I'm trying to exclude activity updates (ones users actually post) from a custom "ticker" I'm running. With the below code, I am only displaying activities where friendships are created. How do I add another argument to allow for another activity action to display? <code> &lt;?php if ( bp_has_activities('action=friendsh...
<code> &lt;?php if ( bp_has_activities('action=new_forum_post,new_blog_comment,new_blog_post,friendship_created,joined_group,created_group,new_forum_topic') ) : ?&gt; </code> Found the solution myself :)
Buddypress Filter Multiple Activities
wordpress
I am going to write my own post display thing, and I cannot find a list of all these type of functions: <code> the_date(); the_title(); the_excerpt(); </code> I'm sure there are more, but where can I find a list?
#1) A doc for a function on WordPress codex lists all related functions at the bottom of the page. For example, this is the doc for <code> the_date(); </code> — look at the section highlighted in the screenshot below: Click on the image to enlarge... #2) Another very good reference is QueryPosts . When you search for a...
Is there a list of all display functions for templates?
wordpress
I've been searching high and low for a php function to set a comments of a given postID open only found function to check what the comment status is <code> &lt;?php comments_open( $post_id ); ?&gt; </code> I need one to set comment would expect it to be <code> &lt;?php set_comments_open( $post_id ); ?&gt; </code> But i...
Have you tried go to Posts and checked the box next to the title and in the dropdown "Bulk Actions" choose Edit and then apply , Comments and in the dropdown "Allow" . And also have added the screen in the post edit area on the tab in the header called "Screen Options" and checked the field called: Discussion? And in S...
Set post comments open function
wordpress
is it possible to remove the current tax term checklist from the quick edit screen? i have switched the metabox for the "subject" taxonomy, to radio buttons, and would like to do the same in the quick edit box. i don't see any filters/hooks for changing the existing method, only an action for adding new items to the qu...
I did solve this by setting the show_ui to false for specific taxonomies... but only on the edit.php screen. Then I added custom columns with my own custom quick edit to mimic the regular quick edit but using a custom Walker. If you add columns with a taxonomy name, WordPress automatically generates the quick edit, so ...
Change quick edit terms list to radio buttons
wordpress
I have installed BBPress in my Buddypress Based Wordpress Site. And i m unable to find any table of bbpress which contains data from the forum in my database. Where can i find it?
As far as I know bbPress uses custom post types. So all the data are in the regular <code> posts </code> and <code> post_meta </code> tables. A look at the source code should tell you more. From the bbPress Codex : bbPress creates three custom post types and adds them to the navigation menu: Forums, Topics, and Replies...
Can't Find BBPress data in Database
wordpress
How can I display WordPress Post Content in 3 Columns and in order using WP_Query(); ? For example, <code> &lt;div class="1column"&gt; Post-1 Post-4 &lt;/div&gt; &lt;div class="2column"&gt; Post-2 Post-5 &lt;/div&gt; &lt;div class="3column"&gt; Post-3 Post-6 &lt;/div&gt; </code> Any help is appreciated! Thanks.
Query the posts like you are known to it, but then get all posts and restructure them for the order you need it. Take care of setting up the global <code> $post </code> variable your own so that to ensure you template code still works. The <code> array_chunk </code> &shy;Docs function normally comes in handy for column...
Display WordPress Post Content in 3 Columns
wordpress
Can someone please explain what the purpose of this code is: <code> $text = str_replace(']]&gt;', ']]&gt;', $text); </code> I'm referring to a line of code inside wp_trim_excerpt() , but I've seen something very similar in some other wp functions as well. On the surface, I would say it's not doing anything at all, but ...
The replacement string contains a HTML entity which when displayed on a browser, looks like the needle string. It's converting > to a HTML entity. Reference: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/formatting.php#L2119
What is the purpose of this line of code in wp_trim_excerpt?
wordpress
I'm generating my CSS dinamically in a function using a link like this <code> &lt;link id="www-core-css" rel="stylesheet" href="http://wordpress/myplugin/theme-css-loader.php?v=1" /&gt; </code> and i was wondering what approach to take. I could either point the href to a file like <code> http://wordpress/myplugin/theme...
This is forked from something I wrote for a similar requirement. <code> empty( $_GET['my-css-var'] ) || add_action( 'plugins_loaded', 'wpse_59089_css' ); function wpse_59089_css() { header( 'Content-Type: text/css' ); // Aggressive caching to save future requests from the same client. $etag = '"' . md5( __FILE__ . $_GE...
I need to generate the CSS for my plugin from a function, how do i map a request to a function in the front-end?
wordpress
For some reason. I do not have the ability to query by meta_key when I run a loop. What could cause this and what can I do to the diagnose the problem? I am using wordpress 3.4.1. <code> $args = array( 'meta_key' =&gt; 'slideshow_image'); $query = new WP_Query($args); </code>
Thanks for @dunc and @helgatheviking I got the answer. Here's my code. You need the post type declared, otherwise it resorts to "post". I also couldn't do this unless I put meta_key and meta_value in a 'meta_query' multidimensional array. <code> $args = array( 'post_type' =&gt; 'tsa_events', 'meta_query' =&gt; array( a...
Can't query by meta_key
wordpress
I imported the blog to my self-hosted WP. I also found the theme I was using, downloaded and installed it. I don't see all the widgets that are available in my Wordpress.com dashboard. I can search for widgets e.g. Twitter but it gives me like 1000 results. I want exactly the one I have on my curren wordpress.com blog....
Try installing the JetPack plugin, which includes several of the .com features for your stand-alone blog. There's a Twitter widget in there that might be the one you were using.
How to find the exact widget details
wordpress
I am trying to send out e-mail, SMS and IM notifications to group members of this WordPress website, whenever a WordPress page in their user group has been published/updated. I figured using the action hook <code> 'save_post' </code> would be the best solution. However, I ran into some annoying factors along the way, a...
Updated: First, you will need to return a bool value on your notifications method so we can reliably set a marker for the message method. Then, you will need to set a $_POST array element to pass on to the redirection filter. <code> public function save_post($post_id){ //Add a $_POST key if you syndicated successfully ...
How to use filter hook 'post_updated_messages' in coherence with action hook 'save_post'
wordpress
While following stackexchange-url ("this article") to get tags by date, I was wondering if I could exclude certain tags from what gets returned. The point is to have trending tags but some tags will always be there and I don't want to include those ones. Here is the code: <code> &lt;?php $how_many_posts = 50; $args = a...
<code> &lt;?php $how_many_posts = 50; $exclude_these_term_ids = array( 10, 20, 35, ); $args = array( 'posts_per_page' =&gt; $how_many_posts, 'orderby' =&gt; 'date', 'order' =&gt; 'DESC', ); // get the last $how_many_posts, which we will loop over // and gather the tags of query_posts($args); // $temp_ids = array(); whi...
Exclude Tags from get_the_tags
wordpress
I am running the newest WordPress and qTranslate. I have made a page that enables some custom fields that are working ok. qTranslate enables languages like tabs when editing a page. But this doesn't happens in my custom meta fields. Any way of making language control on these fields? It would be great if there were som...
Less complicated is to use the plugin's Quicktags and use the Gettext functions to print the content in the site. <code> [:en]English[:pt]Português </code> Quicktags docs Another option is to do just like qTranslate interface does with the post titles: Create one custom field for each language in your meta box: qTrans ...
Custom Meta Field not Working with qTranslate
wordpress
With the help of a couple of users, my last two questions were highlighting a custom menu item through its ID. Now I'm trying to combine the code of the following two functions to make it work by Post Name: stackexchange-url ("Add highlighting to new Admin Dashboard Menu Item") <code> add_action( 'admin_menu', 'create_...
Attention to the use of <code> get_page_by_title </code> parameters. And also to the use of the Heredoc PHP syntax. <code> $the_post_title = 'The Portfolio'; add_action( 'admin_menu', 'wpse_59050_add_menu' ); add_action( 'admin_head-post.php', 'wpse_59050_highlight_menu_item' ); function wpse_59050_add_menu() { global ...
Highlighting a Menu Item by Post Name
wordpress
I'm getting an image through <code> getMeta </code> . It returns me the id of the attachment. Now I want to get the titel, alternative text, description and so on. For the alternative text this works very well: <code> get_post_meta($logo, '_wp_attachment_image_alt', true); </code> Now I want to get the title. I found o...
If you have the attachment id, you can use <code> get_the_title() </code> <code> $attachment_title = get_the_title($attach_id) </code> http://codex.wordpress.org/Function_Reference/get_the_title
get attachment title based on attachment id
wordpress
I'm building a themes options page using settings API. Everything is ok, but i now i want to create a drop down list populated with pages and i don't know how to! For example, i have this piece of code that show the list of pages, but when i select a page and cick on save, the page selected doesn't get saved! <code> fu...
I have found the solution. I used the wordpress function wp_dropdown_pages <code> &lt;?php function combo_select_page_callback() { $options = get_option('function plugin'); wp_dropdown_pages( array( 'name' =&gt; 'function plugin[ID used to identify the field throughout the theme]', 'echo' =&gt; 1, 'show_option_none' =&...
How to create a drop down list with pages to a themes options page?
wordpress
How to limit the function of paging down to stop at number 10? Eg: pages: 1 2 3 4 5 6 7 8 9 10. <code> function kriesi_pagination($pages = '', $range = 2) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query-&gt;max_num_pages; if(!$pages) { ...
<code> for ($i=1; $i &lt;= min($pages,10); $i++) </code>
Limited number of paging to 10 "pages: 1 ... 10"
wordpress
My theme doesn't use the tag line, how can I remove it from the customizer?
Late to the party but this will do the trick: <code> $wp_customize-&gt;remove_control('blogdescription'); </code> You want to remove just that control, not entire section as suggested above.
How do I remove a pre-exising customizer setting?
wordpress
I am going to import my current blog posts on to my future to-be self-hosted wp blog. It will take somedays before I make it the primay blog. In the WP Privacy Settings I have set "Ask search engines not to index this site" Is this setting enough so as to not affect my current page rankings? Or do I need to do somethin...
Install Authenticator . It requires a log-in to access the blog content. A <code> robots.txt </code> is just a recommendation and not safe enough.
Is wordpress Privacy Settings sufficient for this?
wordpress
I am trying to build a widget based on the default wordpress recent posts widget. In wp-includes/default-widget.php , I noticed in <code> class WP_Widget_Recent_Posts </code> in function widget(), the recent posts are first looked for in cache and if not found, then output buffering is turned on and the result is gener...
Unless you have a memcached-type plugin installed, <code> wp_cache_set </code> will only store data for the duration of the current script. Call or add the widget again in the same instance &amp; you'll see it utilise the cache. As for <code> ob_get_flush() </code> , taken from the manual : Flush the output buffer, ret...
How does the default recent posts widget work with cache?
wordpress
A client has requested some interesting functionality. THey have about 20 different scripts, most of which are needed by one page only. They would like an area within Wordpress's pages and custom post types to add scripts for THAT PAGE ONLY. So when that page loads, the script loads in the header or footer, NOT inline ...
I'm assuming that you want to load some post-specific scripts (JavaScript) in header. 1. Using Wordpress Custom Fields One way you achieve this by using wordpress custom fields, While posting new post just add a custom field with name (i.e - <code> header_script </code> ) and enter the Script source in next text-field....
Custom Scripts per page or Custom Post Type
wordpress
I have two domain names: themaindomain.com and thealias.com. Wordpress is located under themaindomain.com. I was wondering if it is possible to change the urls to posts and pages when there is a request from thealias.com To make clear: When there is a request from themaindomain.com, the server returns a page with some ...
You can use the the <code> WP_HOME </code> directive in your <code> wp-config.php </code> . Just set it dynamically based on <code> $_SERVER['HTTP_HOST'] </code> like the example in the codex. <code> &lt;?php define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); </code> You might also want to define <code> WP_SITEURL <...
Change URLs depending on alias
wordpress
I am using the Twenty Twelve theme, and the following is the code it uses to register and display the menu. In functions.php: <code> function twentytwelve_setup() { ... // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) ); ... } add_action( 'after_setup_...
based on : http://wpfirstaid.com/2010/10/extend-the-wordpress-menu/ <code> function wpa_58902($items){ $search = '&lt;li class="search"&gt;'; $search .= '&lt;form method="get" id="searchform" action="/"&gt;'; $search .= '&lt;label for="s" class="assistive-text"&gt;Search&lt;/label&gt;'; $search .= '&lt;input type="text...
Search box as a menu item in the nav menu output by wp_nav_menu?
wordpress
So my custom wordpress theme/site has a number of venues, e.g. "foo" which has a number of events and reviews. So a venue ends up with a URL like, <code> http://www.example.local/places/my-place-name/ </code> But in addition to rendering the venue's content (the_content()... etc) I'm rendering the events and reviews at...
You need to add a query var and rewrite rule to make that work. First, add the query var to WordPress query vars array in your theme's <code> functions.php </code> : <code> add_filter( 'query_vars', 'wpa58904_query_vars' ); function wpa58904_query_vars( $query_vars ){ $query_vars[] = 'my_page'; return $query_vars; } </...
Adding pagination to sub-wp_query within a singular post page
wordpress