question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Hi I have I started to create my first wordpress template yesterday and today I have gotten to the point where I have to create the search page result.From what I found online that should be search.php file.But for some reason it seems Wordpress is not pointing to that page when I try to search.I also created the searc...
That input needs a <code> name </code> attribute of <code> s </code> : <code> &lt;input type="text" name="s" value="type your search" /&gt; </code>
search.php file not pointing where it should
wordpress
I'm aware that this is a known problem but I was unable to address it using information found in WPAnswers and Wordpress support forums. In my Worpdress single site installation the media uploader is always throwing an error at me <code> out of memory (allocated 99614720) (tried to allocate 3760 bytes) </code> the amou...
You're looking at the problem the wrong way. The error you're seeing isn't an error coming from WordPress, it's a PHP error. Somehow, somewhere, something is limiting the memory limit to 96M, and it ain't WordPress that's doing it . Here's the thing: WordPress can't actually limit the memory on most servers. I know tha...
Memory errors with media upload, Wordpress can't use more than 96M (while there's 512 available!)
wordpress
For a project, i've to improve SEO perf and one of this optimization is to load the sidebar with an ajax request. I've looking for this solution through the documentation, source code, plugins repository without success. So i need your help and advices. Is it possible to do this ? If yes, what is the best way ? Thanks.
I didn't test anything, but I imagine it would be something like this: As you must include a <code> sidebar.php </code> , just include an empty <code> sidebar.php </code> , and leave the real one to the <code> sidebar-ajax.php </code> , for example. To call the sidebar: <code> &lt;?php get_template_part('sidebar'); ?&g...
Use ajax request to load sidebar
wordpress
This is really bizarre - this has never happened before :/ I have a search.php template which consists of this... <code> &lt;?php /** * @package WordPress * @subpackage Example 2012 * @since Example 1.0 */ get_header(); ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php ...
Change the form to: <code> &lt;input class="searchform-mid clearit" type="text" name="s" id="search-header" value="Search" /&gt; </code>
search.php template not loading results
wordpress
Hi I am new to template development and today I started my first theme.Things are not going as well as I tought I can't seem to find anything I need in the codex it seems to disorganized to me. I would like to know if there is a function that I can acces the info in the style.css file posted on the top.More specificaly...
You can use - <code> wp_get_theme() </code> - To get current theme data. You also can get information of other themes by passing theme directory name. <code> get_userdata() </code> - To get user data stored in the profile page.
Get data from style.css file and from from users-> your profile
wordpress
I feel like this is probably a duplicate question, but cannot find the search terms to find what I'm looking for. Is it possible to have different category list (archive) pages (or views/templates) based on the post's category? I'm working on a site that's using the blog as a top-level category, but I want my other "pa...
You can create a category template named <code> category-foo.php </code> this will be applied only to category with slug <code> foo </code> . You can thus create custom template for different categories. Source - Codex page for Category template Note - If you want to do some minor changes such as show <code> foo </code...
Category List (Archive) Page Template By Category
wordpress
I have a problem with the <code> posts_nav_link() </code> function on index.php. It works but it's not displaying the older posts. When someone clicks on the "next page" link the same posts from the fist page are loading. This is the code I'm using: <code> &lt;?php if ( is_home ()) {$myquery = new wp_query('cat=-41');}...
You are missing the <code> paged= </code> paramter. <code> $myquery = new wp_query('cat=-41&amp;paged=' . get_query_var( 'page' )); </code> Codex Note - You should set <code> get_query_var( 'page' ) </code> if you want your query to work with pagination. Tip - If you want to eclude a category from main page you can use...
posts_nav_link() not working on index.php
wordpress
Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code: <code> if(function_exists('add_theme_support')){ add_theme_support('post-thumbnails' ,...
It's default behaviour that the images aren't scaled up. Easiest way would be to use simple CSS to scale it up. stackexchange-url ("How to scale up featured post thumbnail?") For the second part set the <code> crop </code> parameter of <code> set_post_thumbnail_size </code> to true. <code> set_post_thumbnail_size( 200,...
Setting thumbnail featured image size not working properly
wordpress
How does everyone work on a live blog in WPMS when the domain name still points to a different server/IP? I need to configure the site before the domain Name Server settings are changed to the new host.
Edit your computer's hosts file , then on a new line, insert the IP address of the new or old server from which you'd want to access the site, followed by a space or tab, then type in the domain name (without http://). Here's an example... <code> # This is an example of the hosts file 127.0.0.1 localhost loopback ::1 l...
How to work on a live WPMS blog when domain is unresolved?
wordpress
I have a theme name is mytheme in <code> themes/mythem/functions.php </code> I using code: <code> function remove_scripts() { remove_action('wp_head','mytheme_head_scripts'); } add_action('init', 'remove_scripts'); </code> => but result can't remove all javascript, how to fix it ?
You either use the <code> admin_*/wp_print_scripts </code> hook or the <code> admin_*/wp_print_styles </code> hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of <code> 0 </code> for the <code> *_print_scripts </code> hook (there might be function with a name...
How to remove all javascript in a theme wordpress?
wordpress
I updated the style.css file of my WordPress installation recently. The change were effective: when logged in as an administrator (my blog is set so that the administrator is never served a cached version of the site, but a “live” one), I can see them. But my blog is being served through a CDN (using W3 Total Cache). T...
You need to either Version your files (by calling it <code> style.css?ver=xxx.xxx </code> ) and making sure your CloudFront distribution has "Forward Query strings" turned on. This is the better option, as it means that all you need to do is increment the number in the query string and CloudFront will fetch this file a...
W3 Total Cache, CDN and theme files
wordpress
Book (Custom Post Type) Fiction (Tax) Science (Tax) History (Tax) ----------OR----------- Book Genre (Tax) Fiction (Term) Science (Term) History (Term) Which of these is "good way" of doing it? With the former one( which is what i have currently in my admin menu, i've 'register_taxonomy' functions for each of them ) i ...
To answer your question ... the 'good' way is the way which ... you are most comfortable with developing, is easy to maintain going forward, and solves the problem. Personally - I prefer flatter taxonomy structures so option 1 ... For Option 2 .... you didn't say if in the future you would have more 2nd level taxonomie...
How to add taxonomy in menus?
wordpress
I will be doing upgrades to the design and content of my Wordpress site. During this time I only want the homepage to be available. Is there a good way to lock this down (through a plug-in, etc.). I'm having trouble coming up with answers from Google. Thanks, Jason
Here is a little snipit of code that I used for my site while it was under construction <code> &lt;?php /* ROUGH METHOD OF DENY ACCESS */ $underconstruct = array(121, 46, 124, 97); if(!is_user_logged_in() &amp;&amp; !in_array(get_the_ID(), $underconstruct)) { wp_redirect(get_permalink(121)); exit(); } ?&gt; </code> I p...
How to limit WordPress pages during updates?
wordpress
In wp-login.php I added my corporate logo. However, when the mouse hovers on it, the disclaimer "Powered by Wordpress" appears. How can I remove it?
Did you check out the codex? http://codex.wordpress.org/Customizing_the_Login_Form What you are refering to is because of the default title attribute on the logo image. You can change that by adding some code to the functions.php file for your theme. Here's how (from the codex): To change the link values so the logo li...
How can I remove "Powered by Wordpress" pop-up disclaimer in wp-login.php?
wordpress
Hi I recently started to learn wordpress theme development and today I started my first worpress theme.For some reason my stylesheet get's loaded in chrome but not in firefox and IE the browsers I am using to test. Something else I noticed is that it seems wordpress adds some additional styles on its own.Here's what I ...
Something else I noticed is that it seems wordpress adds some additional styles on its own.Here's what I found on the source page: When you browse your blog while logged in, wordpress adds <code> 28px </code> margin to top of html/body to make space for their - Wordpress Toolbar And here's line of code from my theme wh...
Stylesheet is not loading on firefox and IE!
wordpress
i am trying to use jscrollpane , but i tried everything , its still not working this is my function page <code> &lt;?php /** * Custom Child Theme Functions * * This file's parent directory can be moved to the wp-content/themes directory * to allow this Child theme to be activated in the Appearance - Themes section of t...
i did it like that and its working now <code> function kia_enqueue_scripts() { //use google's jquery wp_deregister_script( 'jquery' ); wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js'); //load up your own plugin wp_enqueue_script('easing', get_stylesheet_directory_uri() . '/js...
jscrollpane problem with my child theme
wordpress
I use this to query all attachments of the current page or post I'm on … <code> $query_images_args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt;'image', 'post_status' =&gt; 'inherit', 'posts_per_page' =&gt; -1, 'post_parent' =&gt; $post-&gt;ID //$post-&gt;post_parent ); $attachments = get_children($qu...
You can use <code> get_children </code> to check if it returns anything, then if it doesn't, fetch the parent attachments. <code> //loop stuff //your $query_images_args $attachments = get_children($query_images_args); if ( empty($attachments) ) { //go get parent attachments }else{ //loop through this post's attachments...
query attachment images … if no attachments -> get attachments of parent page?
wordpress
So I have been googling for quite some time now and I can't seem to solve this. A lot of sources refer to a file called <code> the_tags.php </code> but it's nowhere to be found. Can anyone point me in the right direction? Thanks.
It's not a php file, it's a core function: <code> the_tags() </code> . <code> &lt;?php $before = ''; $seperator = ''; // blank instead of comma $after = ''; the_tags( $before, $seperator, $after ); ?&gt; </code>
Remove commas between tags
wordpress
At the moment I'm using a custom post type called 'locations' I would like to be able to put input fields into the custom post type that would store the information such as ( address, type, phone number, etc.. ) in a separate table called 'markers' So when a new post is made it will create a new entry in the table mark...
You should avoid creating more tables. Just do it if you really have a good reason to. Note that <code> wp_postmeta </code> can store practically any kind of data, and simply using the <code> get_post_meta </code> function can do all the job in most cases. But if you must use another table, and taking it generally, the...
Custom Post Type with Input fields to seperate table on database.
wordpress
I've created a custom post type (minerals) with a custom taxonomy (location) which supports hierarchies. What I am trying to do is create a return according to the parent location of the mineral post type. For example, someone clicks on Europe, and the results show all minerals from all listed countries in Europe. Now ...
I think you're way overcomplicating this. Use <code> get_terms </code> to get all taxonomy terms that are a child of a particular term via the <code> child_of </code> argument, then use that array with a <code> WP_Query </code> tax query , no custom SQL queries necessary.
Selecting all posts from the children of a particular parent taxonomy
wordpress
I'm using a lot of custom post types for creating sidebars, footers, etc and would like to hide direct viewing of these post types. Is this possible?
<code> register_post_type </code> allows you to specify whether a post is 'publicly_queryable' publicly_queryable (boolean) (optional) Whether queries can be performed on the front end as part of parse_request(). Default: value of public argument Note: The queries affected include the following (also initiated when rew...
Hide directly viewing content for custom post type
wordpress
Im seeing WordPress plugins either use plugins_url or plugin_dir_url when creating constants to some of their folders. Is one better than the other? examples: <code> define( 'MEMBERS_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) ); define( 'WPACCESS_INC', plugins_url( 'inc', __FILE__ ) , true ); </code>
Checkout - wp-includes/plugin.php#L585 <code> plugin_dir_url() </code> function internally uses <code> plugins_url() </code> to get the link to plugin directory. plugin_dir_url() This will return url of plugin directory with a trainling slash at the end. So this can be easily used to link to plugin directory. E.g - <co...
plugins_url vs plugin_dir_url
wordpress
Ive been looking into actions and hooks etc... from wordpress, but cant seem to do a very simple thing. I just want to execute a function whenever a post is updated, and within the function I want the names of the terms that have been changed on that save. So maybe some sort of before and after comparison of terms?? Co...
After WordPress has updated a posts' taxonomy terms it triggers the action: <code> set_object_terms </code> ( see source ) which passes 6 variables: Object ID Terms that were assigned to the post (or added depending on 5) (could be their slug or term ID). Taxonomy-term IDs of above (not term IDs) The taxonomy Append. I...
Creating a function that receives the taxonomy terms that have been changed in a custom post type
wordpress
I have a simple Navigation: Blog, About, Contact . Mainsite is Blog . To keep the current Button highlighted, I used this in my CSS: <code> li.current_page_item a{ border-bottom: 1px solid #212121; padding-bottom: 1px; } </code> It works pretty fine. But I want to keep Blog still active while I’m listing an item from m...
Okay, I did it this way:: <code> add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ if(is_category() &amp;&amp; $item-&gt;title == "Blog"){ //Notice you can change the conditional from is_single() and $item-&gt;title $classes[] = "special-class"; } return $clas...
Dont’t change active Button while I’m listing a category?
wordpress
I checked that there is an shortcode on wordpress.com but it seems there is no build in way of adding the shortcode of archive on wordpress.org site. I know there was one plugin in repo but it's 2 years old with no updates in code. So let's say if i want to return the archive. following shortcode doesn't work. Is there...
That is not a shortcode. Take a look at the Shortcode API for examples of how to do this. Here is your specifc example: <code> function wpse61674_archives_shortcode_cb( $atts ) { return wp_get_archives('type=monthly'); } add_shortcode( 'archives', 'wpse61674_archives_shortcode_cb' ); </code>
How to Make Archive ShortCode
wordpress
Say my wordpress install is here, example.com/wp/ but my .htaccess is in example.com, am I ok with <code> &lt;Files wp-config.php&gt; Order Allow,Deny Deny from all &lt;/Files&gt; </code> or do I need to specify a directory? <code> &lt;Files /wp/wp-config.php&gt; Order Allow,Deny Deny from all &lt;/Files&gt; </code>
Only the first version works... <code> &lt;Files wp-config.php&gt; Order Allow,Deny Deny from all &lt;/Files&gt; </code> As per the current documentation , in <code> &lt;Files filename&gt; </code> , the filename should include a filename, or a wild-card string, where ? matches any single character, and * matches any se...
Hiding wp-config.php via .htaccess on an install installed in another directory?
wordpress
i have a blog page template , i need to make it display posts from specific category called news this is the template , i use thematic framework child theme <code> &lt;?php /** * Template Name: Blog * * This template allows you to display the latest posts on any page of the site. * */ // calling the header.php get_head...
Try changing : <code> $wp_query-&gt;query( array( 'posts_per_page' =&gt; get_option( 'posts_per_page' ), 'paged' =&gt; $paged ) ); </code> to <code> $wp_query-&gt;query( array( 'category_name' =&gt; 'news','posts_per_page' =&gt; get_option( 'posts_per_page' ), 'paged' =&gt; $paged ) ); </code> You need to use slug, in ...
display posts from specific category on a page , in thematic child theme?
wordpress
When my plugin is activated, I would like to add a new menu item. Here is my code: <code> class My_Plugin { function __construct() { register_activation_hook(__FILE__, array($this, 'install')); } function install() { add_action('admin_menu', array($this, 'add_menu_item')); } public function add_menu_item() { add_menu_p...
Plugins are activated in a sandbox and their output is captured to check for errors, and redirect if activation was successful. Adding something in an activation hook will cause it to run once in that "invisible" sandbox on activation, and that's it. When you add an action, you're only adding it for that request , if y...
How to add custom menu item on plugin activation?
wordpress
I'm a combination Drupal and WordPress developer and have recently started playing with Drupal's Panels module -- which allows you to create flexible layouts and drop content blocks (The Drupal equivalent of widgets) in place on either a per-layout or per-content item basis. I'm now working on a WordPress project that ...
There's been a lot of development in this sphere since I posted this question, not only in using visual layout tools for the overall site theme, but also for laying out individual pages. Some plugins I've evaluated: SiteOrigin Page Builder has a Panels-esque fluid grid layout engine, into which you can place any kind o...
Drag-and-drop "Panels"-style visual layout editor?
wordpress
I'm working with submitting posts from fronted which has some custom fields. I used shortcode API to use the form in any page/post. The code should be found bellow. But after submitting the form, nothing happened and the form returns. I need your kind help. <code> &lt;?php //Shortcode API function apl_video(){ global $...
Your code works fine for me as-is, assuming you actually have a <code> video </code> post type, however there are a couple of things you can correct- shortcodes should <code> return </code> their value, otherwise you will see shortcode content appear before any post content, not where you actually placed the shortcode....
Post Submission from frontend with custom field isn't working
wordpress
OK so I've searched a lot and couldn't find a straight forward answer to my question. I am simply trying to use one category loop that will display posts in a category page in a wordpress site. lets say 6 posts for this purpose. it's pretty simple to accomplish it by using a simple query loop like so: <code> &lt;?php q...
Just create 2 queries using the "offset" parameter and separate them by: <code> &lt;?php wp_reset_query(); ?&gt; </code> Display posts from the 4th one (offset is starting from 0): <code> &lt;?php $query = new WP_Query( 'offset=3' ) ); ?&gt; </code> EDIT: Here's some sample code: <code> &lt;?php query_posts('offset=0&a...
Split wordpress loop to multiple layouts
wordpress
I currently have Windows 7 , 64 bit on which I am running an IIS on localhost:80 and I installed XAMPP on localhost:8080. I have 15 individual wordpress sites but now i need a subdomain multisite wordpress. I created wp.dev:8080 in the hosts file for multisite, and correctly amended the apache virtual file. All worked ...
Ok, I gave up and moved to port 80, though i think what @Boultge suggest (the link) would have probably done it, but I read it too late. Here are the files tho that are letting me run XAMPP WordPress MU sub-domain Multisite on localhost as wp.dev with 20 additional WordPress individual sites. I shortened it because i h...
Wordpress Subdomain MultiSite on localhost XAMPP on :8080 with IIS taking port 80
wordpress
On my WordPress site I've got a social sharing bar that I created myself. Here's a picture of the social sharing bar: http://d.pr/i/ucSG - I have the social sharing links included within 'index.php' between: <code> &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;div class="fb-like" data-se...
I think your code should be in <code> header.php </code> or <code> single.php </code> and not index ...these are the correct parts of the theme that get called with every post or page. That should fix part of the problem. Also ... With Twitter Tweet buttons , for example, you can have extra meta such as the <code> data...
Social Media Links on homepage - within posts/post loop
wordpress
After run a query <code> $posts = (array)new WP_Query($args); </code> I use this data to do some calculation on post meta. I didn't display the posts. Do I still need to use <code> wp_reset_postdata </code> after the query?
If you called the_post() on the query, then yes. This resets the global variables used in the main queries.
Is wp_reset_postdata always necessary?
wordpress
I just tried to compress a file and am not sure if it worked or not. The plugin I am using gave me the following results: <code> adding: wp-includes/js/tinymce/plugins/wpeditimage/editimage.html (deflated 76%) adding: wp-includes/js/tinymce/plugins/wpeditimage/php.ini (deflated 64%) adding: wp-includes/js/tinymce/plugi...
Without going into the Plugin code and then figuring out the PHP method used to create the zip archive you're better off just opening the file and checking the contents as @fdsa suggests. The <code> stored 0% </code> would indicate there was nothing in the directory to add to the archive. The <code> deflated xx% </code...
What does the output of this plugin mean?
wordpress
I'm not sure what's happening here, since this has worked in another plugin I've created. I'm simply trying to store data in the options table. Here is the code I'm using: <code> function on_myplugin_start () { register_setting('first_tab_options', 'first_tab_items'); } add_action('admin_init','on_myplugin_start'); </c...
...because your input (POST) name needs to match the one in your <code> register_setting </code> call: <code> register_setting( 'first_tab_options', 'first_tab_items' ); .... &lt;input type="text" name="first_tab_items"... </code> Otherwise how the hell does WP know that <code> some_name </code> in POST holds your opti...
Plugin options will not save in database
wordpress
I am creating a plugin to display all posts from all custom post type. It is something like in edit.php, but instead of displaying single post type,I would like to display all posts in one page from multiple custom post type. I follow the tutorial at here to create the plugin and I did it. However there is one problem ...
Just use <code> get_delete_post_link( $post_ID ) </code> - it'll return the absolute URL with nonce and all! Just to be clear , this will get the link to trash posts (if trash supported). If you want to skip trash &amp; get the perma-delete link , pass a second argument of <code> true </code> *. http://codex.wordpress....
How to use wp_nonce_url() in a link?
wordpress
I'm using a few plugins that have shortcodes ... however, instead of creating a public page for the content, I've created some new pages within the admin using <code> add_menu_page </code> and I need to know how to utilize <code> do_shortcode() </code> within this context. As it stands, all the function does it spit ou...
Instead of calling <code> do_shortcode() </code> just call the function associated with the shortcode. Example There is a shortcode named <code> [example] </code> and a function registered as shortcode handler: <code> function example_shortcode( $atts = array(), $content = '' ) { extract( shortcode_atts( array ( 'befor...
do_shortcode() within Admin Page
wordpress
OK I'm trying to load content of a post via AJAX. So here is the functions.php part <code> wp_localize_script('ajax-script', 'ajax_object', array('url' =&gt; $blogurl,'path' =&gt; $path,'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ))); add_action('wp_enqueue_scripts', 'javascripts'); add_action('wp_ajax_ajax_action', 'a...
If your javascript <code> action </code> is named <code> ajaxify </code> , then these should be: <code> add_action('wp_ajax_ajaxify', 'ajaxify'); // ajax for logged in users add_action('wp_ajax_nopriv_ajaxify', 'ajaxify'); // ajax for not logged in users </code> the actions you hook are a concatenation of <code> wp_aja...
Trying to load content of a post via AJAX
wordpress
When run a query with WP_Query method, I got an object. I understand that I can then do the loop to display stuffs. But, my goal is not to display anything, instead, I want to get some post data by doing something like "foreach...". How can I get an array of post data that I can loop through and get data?
You should read the function reference for WP_Query on the WordPress codex. There you have a lot of examples to look at. If you don't want to loop over the resultset using a <code> while </code> , you could get all posts returned by the query with the <code> WP_Query </code> class method <code> get_posts() </code> . Fo...
How to get an array of post data from wp_query result?
wordpress
I am working on a site. This site has a built in layout organize that uses a switch statement to organize data on a page. I want to use that to organize the homepage posts. Right now, there are 4 posts that I have a loop set up to return. Here is the loop I am running <code> query_posts( array ( 'category_name' =&gt; '...
Use get_posts instead - You can use the function <code> get_posts() </code> to get all the posts as array. This function accepts almost all parameters that of query post's. Example - <code> $args = array( 'numberposts' =&gt; 3,'category' =&gt; 3 ); $homePost = get_posts( $args ); $one = $homePost[0]; $two = $homePost[1...
how to store wordpress loop in array?
wordpress
By default, wordpress remove accents and weird characters to generate <code> post_name </code> in wp_posts table. This post_name is used when we change the permalink structure to <code> /%postname%/ </code> or some similar structures. In my language, i don't want to remove and replace many characters as it distorts the...
Why did you want to alter the URI here? SEO optimization? An URI has a limited number of allowed chars, defined in an RFC. That's the reason WordPress uses <code> utf8_uri_encode </code> to generate a permalink based on the posttitle. You can find more information in this stackoverflow question: stackexchange-url ("Whi...
permalink error when modifying sanitize_title_with_dashes function
wordpress
How can you load a custom made Roller Theme for Jquery ui to wordpress? I recently created and downloaded a new theme for the datepicker, but can't get it loaded. I tried adding the css file to my theme files then doing an 'enqueue style' function, but seem to be missing something. <code> function my_add_styles() { wp_...
The most important thing is to hook the functions, that register/enqueue your styles and scripts, at the right "time". This would be on the <code> admin_*/wp_*/login_enqueue_scripts </code> -hooks. Read about the instruction on WPDevel. This answer stackexchange-url ("provides even more details about the process of reg...
Jquery Theme Roller to Wordpress
wordpress
Thanks to Author for this plugin. But There is no option to display subtitle. There is only 2 options - Title and excerpt. Help me change excerpt to subtitle. I use this function to display subtitles in posts : <code> &lt;?php if (function_exists('the_subtitle')){ the_subtitle(); }?&gt; </code> This is file of fronpage...
Subtitles aren't standard in wordpress so it's hard to know where to find yours. This code needs to be placed in the <code> frontpageSlideShow </code> function. Below where it says <code> //format informations </code> add: <code> $subtitle = //wherever your post subtitles can be found, probably in a custom //meta </cod...
Include subtitle display to slideshow
wordpress
Hi a new version of a plugin I have in the repository changes the way the data is stored in the database, how can I perform a check on upgrade that automatically moves the data to the new location, so the users don't lose any of their settings and are not aware of what is happening beneath the hood?
<code> global $myplugin_db_version; $myplugin_db_version = "1.0"; function myplugin_install() { global $wpdb; global $myplugin_db_version; $table_name = $wpdb-&gt;prefix . "myplugin"; $installed_ver = get_option( "myplugin_db_version" ); if( $installed_ver != $myplugin_db_version ) { $sql = "CREATE TABLE $table_name ( ...
Run function on plugin upgrade
wordpress
After the body tag, Wordpress is outputting the site url &amp; site name in the Login page (wp-login.php). I think do_action( 'login_head' ); is responsible somehow but not sure how to modify this without touching the core file. Update While browsing through the functions.php file, i discovered the code below and there...
If you want to change the logo, you could hook into <code> login_head </code> and output css that replaces the default logo. This goes into your functions.php. <code> function my_custom_login_logo() { // as below or link to an external .css-file echo '&lt;style type="text/css"&gt; div#login h1 a { background-image:url(...
URL and Site title outputting on Login page
wordpress
I have got a Wordpress website and I would like to create a new one with exactly the same functions, themes/templates (apart from the color), plugins, etc. An exact clone of the current one, but with different content and name of sections. Is there any plugin I can use or should I just copy the website, delete contents...
Built in! WordPress comes with feature for this: »MU« or Multisite or Network. You can read more about it in Codex . Summed up The most important part is a single line in your <code> wp-config.php </code> file: <code> define( 'WP_ALLOW_MULTISITE', true ); </code> Then you have to decide whether you want to use sub doma...
Clone a wordpress website with same functionality, but different content
wordpress
I am attempting to alter the query of pages where the post meta value of <code> _members_access_role </code> does not meet that of the currently logged-in user. Here is what I have so far: <code> // Get all posts with the access level of 'Member' function members_get_member_posts() { $post_ids = array(); $args=array( '...
Try this version: <code> // Get all posts with the access level of 'Member' function members_get_member_posts() { $post_ids = wp_cache_get( 'wpse61487_members_posts' ); if ( false === $post_ids ) { $post_ids = array(); $args=array( 'post_type' =&gt; 'any', 'meta_key' =&gt; '_members_access_role', 'meta_value' =&gt; 'me...
pre_get_posts Remove posts based on meta value with 'post__not_in'
wordpress
I'm considering the saving of options for a plugin I'm developing. The first obvious candidate is the wp_options table. While reading the Pro WP Plugin Development book I came across this: Every option saved adds a new record in WordPress ’ option table. You can simply store several options at once, in one array: This ...
Store the options in a single array and write your plugin as a class. Load the options in the constructor and save it as a member variable and you'll have access to it everywhere in the plugin.
Efficient way of saving plugin options
wordpress
Currently i am using the following generic flow for adding the shortcode for a plugin. <code> class MyPlugin { private $myvar; function baztag_func() { print $this-&gt;myvar; } } add_shortcode( 'baztag', array('MyPlugin', 'baztag_func') ); </code> Now when this class and it's method are called i get the following error...
As the error says you need an instance of the class to use <code> $this </code> . There are at least three possibilities: Make everything static <code> class My_Plugin { private static $var = 'foo'; static function foo() { return self::$var; // never echo or print in a shortcode! } } add_shortcode( 'baztag', array( 'My...
PHP error with shortcode handler from a class
wordpress
Can we give role parameter the value of pending in wp_insert_user ?
You cannot set a value as pending ( left the <code> role </code> parameter blank ) to not enter a user role value into database using function - <code> wp_insert_user() </code> . See - <code> wp-includes/user.php # L1363 </code> NOTE - <code> wp_insert_user() </code> function sets a <code> default </code> role if you d...
Can we give Pending as a Role to wp_insert_user?
wordpress
With the following code in functions.php - <code> wp_get_attachment_metadata() </code> returns false and or empty. Perhaps I am attempting to use <code> wp_get_attachment_metadata() </code> before it's ready? As some tests have shown when manually add a previously added <code> $attachement_ID </code> I get the desired ...
'add_attachment' runs right after an attachment is added to the DB, but but before the metadata is generated. If you don't need the value to be in the database yet, you can use the 'wp_generate_attachment_metadata' filter to hook in. However, if you need the data to be in the database already, you'll have to use 'updat...
wp_get_attachment_metadata returns false with add_action() 'add_attachment' hook
wordpress
I am using WP to Twitter on my WordPress blog to trigger a tweet every time I post something. Obviously this is for Twitter only, I need something to post on Google+ too.
As noted above - not currently, but you may want to keep an eye on Simple Google Connect . Otto has created other social connect plugins that are quite popular. Thanks!
Is there a WordPress plugin that can post to Google+?
wordpress
I am looking for a plugin which could publish my site rss to facebook timeline automaticlly. The function like <code> rssgraffiti.com </code> . For explain, if my wordpress site's rss (blog, post, bb press, buddypress stream, etc) updated, it will automaticlly publish to my facebook timeline. (Or if there is not a plug...
The official Facebook plugin seems to have that functionality. Look for the Social Publisher feature. It says: " ... allows you to publish to an author´s Facebook Timeline and Fan Page "
Looking for a plugin which could publish my site rss to facebook timeline automaticlly
wordpress
When a user activates the TwentyEleven theme in the admin widgets area, the user already has the Main Sidebar populated with a few standard widgets. Could someone explain or point me in the right direction about how I could implement the same behavior for my widgets on another theme?
That's not actually installed by the theme. Those widgets are set up as soon as you install WordPress the first time. It's just that if your theme doesn't support widgets, you won't see them. The part of WordPress that "installs" these widgets can be found in <code> wp-admin/includes/upgrade.php </code> inside the func...
Pre-install widgets in WP-Admin
wordpress
I use yoast for my seo, indexing, title, sitemap etc. But I have one issue, for my product pages I want to use costum taxonomy data and yoast doesnt support that. Now I got the code to echo the exact title I want in the product pages but how do I let it overwrite the title set by yoast, or how do I replace the title se...
The WPSEO plugin by Yoast has a filter for the title: 'wpseo_title'. You'll need to add something like this: <code> add_filter('wpseo_title', 'filter_product_wpseo_title'); function filter_product_wpseo_title($title) { if( is_singular( 'product') ) { $title = //your code } return $title; } </code>
Using php to overwrite or replace title tag, while using yoast
wordpress
I need to verify if the media-upload screen came from a click on the "feature image link" on the admin screen. How can i do it? I've already change the way the uploader works , but I need to check this because there is a special flow for the featured image upload.
There is a filter for the html of the 'postimagediv' called 'admin_post_thumbnail_html'. There may be more elegant ways, but this works: <code> add_filter('admin_post_thumbnail_html', 'wpse61502_change_thumbnail_link'); function wpse61502_change_thumbnail_link($content) { return str_replace('media-upload.php?', 'media-...
How to check if upload window came from the featured image link?
wordpress
I'm using a Custom Post Type product with the Custom Taxonomy product_category . When editing a product in WordPress, there is a problem with displaying the product categories tree view right. When an item is checked, it will move to the top of the list. When this item is a top level category, the child categories stay...
Found a solution. It is a WordPress builtin functionality, not a bug. Could be prevented with the 'wp_terms_checklist_args' filter. Below an example for use with Custom Post Type 'product' and Custom Taxonomy 'product_category': <code> add_filter( 'wp_terms_checklist_args', 'checked_not_ontop', 1, 2 ); function checked...
Custom Taxonomy tree view not showing correctly in backend
wordpress
I've been trying a lot of things so far and investigated core inside out, but couldn't find a way that allows me to add the submenu item , but doesn't add the meta box for a custom taxonomy. The Menu item <code> // From: ~/wp-admin/menu.php // That is the file that builds the menu and submenu entries. // This is the pa...
As per le comment. <code> function remove_artist_meta() { remove_meta_box( '{taxonomy name}', 'post', 'side' ); } add_action( 'admin_menu' , 'remove_artist_meta' ); </code> The Admin menu has been always difficult to deal with, some help here would be nice: http://core.trac.wordpress.org/ticket/12718 But I think that t...
register_taxonomy - show in admin menu, but not on post type (edit) screen
wordpress
I am working on a plug-in for my personal site and I would like it have a certain permalink structure (/projects/project-type/sub-type/project). To achieve this, I am using the <code> request </code> filter. Inside my hook method, I am checking to make sure that the taxonom(y|ies) (project_type) exists before I load th...
While I don't see particular problem with this, you do kind of break out of code flow at early point. I would try to go for setting query to <code> is_404 </code> instead and let it reach template processing and 404 in template hierarchy naturally.
Safe to throw 404 error in request filter?
wordpress
There are a variety of tables (page-level, not database) in a website I manage that need to be regularly updated. The difficult issue is that this information is often only one or two data columns, so I usually snake the data into multiple columns. Here is an example. This reduces scrolling and fills the page much bett...
Though I don't think this is really a WordPress question, I'll go ahead and answer anyway. ;-) I think you'd be much better off using an unordered list and some css to get the 2 column effect you're looking for without much effort when updating. The markup for your lists would look something like this: <code> &lt;ul id...
Simple Data Table Update and Page Integration
wordpress
I need help with one redirect, unfortunately I don't have idea how to write this for Wordpress. Should be .htaccess redirect or function in functions.php? Noob I am, so please help :) OK, I have post, for example <code> mysite.com/post1/ </code> now, i have plugin that adding image to post as <code> mysite.com/post1/th...
You should solve this at the plugin level. While this rewrite rule … <code> RewriteRule (.*)/?mysite.com/(.*) /$1/$2 [L,R=301] RewriteRule ^(.*)THUMB /$1 [L,R=301] </code> … does what you are asking for, it is just cosmetic. Find the code that creates the wrong URL and fix that. Give the plugin author feedback; I’m sur...
Need rewrite for URL with specific string
wordpress
I've got a special "position" meta field for posts which can be between 0 and 37. 0 Is ignored, and everything else can have obviously any number between and including 1 and 37. But this of course means that multiple posts can have the same number. Now I'm trying to select only the latest entry from these duplicates, h...
I found out I could just group it by <code> wp_postmeta.meta_value </code> on it's own (without <code> wp_posts.ID </code> ) and it worked! So it ended up becoming as follows. The PHP: <code> add_filter("posts_groupby", "foo_posts_groupby"); function foo_posts_groupby( $groupby) { if (!is_admin() &amp;&amp; is_home()) ...
Distinction on meta value on pre_get_posts
wordpress
For a website I am developing I have to create two pages with listings of courses. The first page is a "Trainings" page while the other page is "Coaching". I would like to use a single custom post type for the content of the courses, because this will be the same for the all the courses on the Trainings and Coaching li...
There are several ways to set this up. I´ll explain how I would do it, using as much of WordPress default settings and functionality to keep things simple. Post Types I´d start with creating 2 custom post types: trainings and coaching . The name of the post type will be added to the URL, so now your courses are accessi...
What approach should I take for this URL structure?
wordpress
I added a new menu item for my plugin like this: <code> add_menu_page( 'Control Panel', 'My Plugin', 'manage_options', 'control-panel', array($this, 'control_panel_page'), plugins_url('/images/menu_icon.png', __FILE__) ); public function control_panel_page() { // My HTML goes here } </code> However, I feel uncomfortabl...
From the codex page : $menu_slug (string) (required) The slug name to refer to this menu by (should be unique for this menu). Prior to Version 3.0 this was called the file (or handle) parameter. If the function parameter is omitted, the menu_slug should be the PHP file that handles the display of the menu page content ...
How to point "add_menu_page" to HTML file rather than PHP function
wordpress
If I add more than 5 Settings to a single section, the order of the settings gets weird. For example: <code> // Link color $wp_customize-&gt;add_setting( 'tonal_'.$themeslug.'_settings[link_color1]', array( 'default' =&gt; $themeOptions['link_color1'], 'type' =&gt; 'option', 'sanitize_callback' =&gt; 'sanitize_hex_colo...
If you need them in a specific order, then give a priority value to the controls. Otherwise, their order is not defined and cannot be guaranteed. If you don't define a priority, then the control gets the default priority of "10". When two controls have the same priority, then the resulting order is undefined, because t...
Theme customizer - settings order
wordpress
I have a taxonomy called <code> mailers </code> And I am adding new terms to this taxonomy on a monthly basis. For example these are my 4 recent terms (slugs) I have added... <code> 'august-2012-newsletter' 'july-2012-newsletter' 'june-2012-newsletter' 'may-2012-newsletter' </code> Is there anyway way to get the latest...
The latest term means it'll have the highest term_ID right, So we're sorting terms in <code> DESC </code> order and getting first array element of the result in <code> $latest_mailer </code> variable. Here's code to do that, not tested but if didn't worked - you can modify <code> get_terms() </code> function to return ...
get latest added term from taxonomy and insert into php variable
wordpress
Im developing a theme for article directory and i would like to link some way taxonomies to taxonomies. I had a custom post type called " company " with 2 taxnomies <code> Taxonomy #1 is category with terms(shops,workshops,churchs,shoppings,etc) Taxonomy #2 is location with terms(New York, New jersey,Miami, etc) </code...
With reservations, sure, you can do what you want with this code: <code> add_action('init', 'wpse_61376_rewrites'); function wpse_61376_rewrites() { add_rewrite_rule('^([^/]*)/([^/]*)/?$','index.php?category=$matches[1]&amp;location=$matches[2]','top'); } </code> Then go to Settings &rarr; Permalinks in wp-admin and cl...
Many to Many Taxonomies or rewrite rules?
wordpress
I'm having trouble implementing a way of using the set WordPress post thumbnail as a background for a div which will include the whole post. Basically, I need a way to call for the thumbnail URL in the index.php file. Something like this <code> &lt;div style="background: url(&lt;?php if ( has_post_thumbnail() ) { the_p...
<code> &lt;div&lt;?php if ( $thumbnail_id = get_post_thumbnail_id() ) { if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) ) printf( ' style="background-image: url(%s);"', $image_src[0] ); } ?&gt;&gt; </code> Code should be pretty self explanatory - codex on wp_get_attachment_image_src . As for...
Use post thumbnail as div background
wordpress
Why doesn't it shows terms in both 'lunch' and 'dinner' taxonomies? How can i do it? <code> &lt;?php $taxonomy = array('lunch', 'dinner'); $orderby = 'name'; $hierarchical = 1; $title = ''; $args = array( 'taxonomy' =&gt; $taxonomy, 'orderby' =&gt; $orderby, 'hierarchical' =&gt; $hierarchical, 'title_li' =&gt; $title )...
Have you noticed in the list all of valid Parameters for <code> wp_list_categories() </code> function that <code> taxonomy </code> doesn't accept input as array, thats why you are not supposed to pass an array to it. If you still want to be able to show terms of two different taxonomies, use <code> get_terms() </code> ...
multiple taxonomies in wp_list_categories' $args
wordpress
I want to have the ability to use pictures from the media library in a jquery slider on the home page so that it's easy for someone else to update the pictures without having to hardcode it. I have attached a bunch of photos to a post and tried this <code> &lt;?php $image_query = new WP_Query(array('name'=&gt;'slider-i...
It's better to use get_children than get_posts. Here is a quick example that will work. This is in the form of a function that is defined in your plugin or in functions.php then use the function as a template tag. <code> /** * Gets all images attached to a post * @return string */ function wpse_get_images() { global $p...
get images attached to post
wordpress
I am needing help figuring out my main navigation bar. I had created it with the default navigation hook but now want the ability to hide pages so they do not show up on the main navigation. However whenever I add a new page it automatically shows up in the navigation (but I do not want this, such as the case of 2009 G...
You were missing an element <code> container_class </code> Try this - <code> &lt;div id="access" role="navigation"&gt; &lt;?php wp_nav_menu( array ( 'container_class' =&gt; 'menu-header', 'menu' =&gt; 'Main' ) ); ?&gt; &lt;/div&gt;&lt;!-- #access --&gt; </code>
Changing from primary to a custom menu changes my CSS navigation layout
wordpress
I want to add different custom fields to comments that belongs to different user group, and display different types of comments in different ways. But WP has some default comment types that shows the type column probably is not for this job. Would anybody make this clear for me?
Taking a quick look at <code> comments.php </code> , I can say - using custom comment type is so far legal, however I didn't played with this yet but you can, and post back with your results if you found any illegal stuff in this. I found on codex the <code> get_comments() </code> function is accepting <code> comment t...
Can I create a new comment type?
wordpress
I have a dilemma in how the data in this scenario should be organised, as well as queried. The main elements in the scenario are the following: Competition Team Player Each player plays for one particular team. Each team participates in one or more competitions. First I'd like to know how this data should be stored wit...
Another perspective. Instead of using the two custom-post-type 'team' and 'player'. You can use them as a single custom-post-type 'participant'. Participant itself is a hierarchical post type, teams as the first level and player as it's child. That way there wouldn't be a player with more than 1 teams. If you are doing...
How to organise this data within WordPress
wordpress
I'm wondering what is the use of the wp_links table, couldn't links have been implemented as a custom post type, if the menu system also uses custom post types?
In short YES , they could have. As anything else could have been implemented as custom post type and/or custom taxonomy. But WordPress is a grown system - now 9 years old - and things are moving slowly to keep most stuff backwards compatible. In short, with WP 3.5, the Links Manager will be moved to a plugin, as you ca...
What is the use of the wp_links table?
wordpress
I'm writing a plugin that creates an API endpoint that validates username/password pairs. I'm currently using <code> wp_signon() </code> to check whether the username/password combo works. This works fine when the credentials fail because it returns an error object. But when the credentials are good, it automatcially s...
There is a function in the <code> user.php </code> of the core files called <code> wp_authenticate_username_password </code> that seems like what you're looking for. If you want to avoid throwing in the <code> $user </code> object (you probably only have the username + password), then just throw <code> null </code> as ...
How to check username/password without signing in the user
wordpress
I would like to get some opinion about using WordPress as a data intense Web Application, let say like rememberthemilk where a user can have multiple post (task) just in a single day. Or maybe like twitter where one can even have multiple post (twitter) in an hour. Another point is that those web application is open fo...
Its more than possible to create a data-intensive, even real-time web application, using the WordPress platform as a base framework. The WordPress database architecture is as such that is suits websites that are either blogs or content management systems of some kind. What is defined as being a CMS-like-site can be wid...
WordPress as a data intensive web app
wordpress
I thought that I got this working but unfortunately it is not. I need my static home page to have an excerpt length of 50 and every other pages to have one of 20. Here is my code so far: <code> function custom_excerpt_length( $length ) { if(is_front_page()) $content='excerpt'; return 50; } add_filter( 'excerpt_length',...
How filters work Filters are simply a point where you can take some value, that is set (for something) in core (for e.g. the <code> the_excerpt() </code> function), in open to modifications. So... <code> $some_var = apply_filters( 'change_this_var', 50 ); </code> ...just says: »Some var« is set to <code> 50 </code> , b...
Custom excerpt length on home page
wordpress
I'm using a custom post type and a custom taxonomy to display a list of properties and its type in a page. It's working fine but for some reason some of my posts' taxonomies aren't getting saved correctly, for example I have 4 categories in my custom taxonomy: storage, home, apartment and other, if I check the home opt...
Maybe it has something to do with the name of your custom taxonomy. <code> Type </code> is a reserved term (see the complete list at the bottom of this page ). Try changing the name and see if it works. Also, did you flush the rewrite rules by going to Settings > Permalinks and click save?
Custom taxonomy not saving correctly
wordpress
If I set up a theme options page in the way suggested by the codex (http://codex.wordpress.org/Creating_Options_Pages) then my form submits to 'option.php'. <code> settings_fields </code> creates a nonce, which if I was creating my own submission page would be checked with <code> check_admin_referer </code> . My questi...
You do not need to use <code> check_admin_referer </code> . If you are using the Settings API then WordPress handles nonce checking and saving data to the database. In terms of data validation, the only thing you need to provide is a validation callback. This callback receives all inputs with name specified in the seco...
Use of check_admin_referer with theme options and options.php
wordpress
I am trying to display current post author link above the loop (before loop starts) with this tag <code> the_author_posts_link() </code> but it's not displaying the author post link. Anyone please help me. Edited question: So I want author post links like this September 17th, 2008 by (here will be author name with post...
It make use of global variable <code> $post </code> to get author id of current post. Using that this function returns the author url. Note - Make sure you put this in condition ( <code> is_single() </code> ) so it only print author url on <code> single.php </code> . <code> &lt;?php echo get_author_posts_url( $post-&gt...
Display Post Author Link above the loop
wordpress
My problem: I'm trying to create a filter that will add the featured image of a post to the_content, so that I can have the first paragraph of the_content displayed before this image. What I basicly want to achieve: <code> &lt;p&gt;First Paragraph of the_content&lt;/p&gt; &lt;img&gt;The Post's Featured Image&lt;/img&gt...
You can do this using the 'the_content' filter: <code> add_filter( 'the_content', insert_featured_image, 20 ) function insert_featured_image( $content ) { $content = preg_replace( "/&lt;\/p&gt;/", "&lt;/p&gt;" . get_the_post_thumbnail($post-&gt;ID, 'post-single'), $content, 1 ); return $content; } </code> Of course, yo...
How do I add the featured image to the_content after the first paragraph?
wordpress
We have a setup where bloggers can and will have their theme changed. Is it possible to migrate the existing header image to the new theme ? I know how to override the header image with the add_filter, also know how to get the current header image. The issue here is to keep the header image when changing the theme. Is ...
We did a small mu-plugin that solved our issue. Here is the code <code> add_action('pre_update_option_stylesheet', 'phi_pre_update_option_stylesheet'); add_action('switch_theme', 'phi_switch_theme'); function phi_pre_update_option_stylesheet($stylesheet) { update_option('previous_header_image_saved', get_theme_mod('hea...
Howto keep header image when changing theme
wordpress
I’m using Excerpts with post-thumbnails on my startsite. Adding Images is working pretty fine. But how can I embed a video from vimeo or youtube as a post-thumbnail? Just the video in a smaller size, not a screenshot. Any ideas?
You could make a plugin which adds a meta box in admin, where you can add a link to a youtube/vimeo video. The plugin should then save the url as meta data for that article when the article is saved. When listing the articles (or viewing a single one), check if the meta data value is set. If it is, then output the corr...
Adding Videos as post-thumbnails (no stills, just the player in a smaller size)
wordpress
I have never used Jquery before so I am quite stuck. The datepicker calendar that gets displayed is not quite what I am looking for, so I am looking to customize it, but don't even know where to start since I am not sure how to use jquery. So here is my current calendar: http://imgur.com/dwv5f All I want though is a si...
Here´s something to get you started. Adapt the code below to your needs Create an init.js file with notepad and paste your code in there Save it in a logical place your theme folder (the JS directory for example) Register and enqueue this file (make sure to load it after jquery) Datepicker set up: <code> /* http://code...
Customizing the Jquery Calendar
wordpress
Does anyone know a way (plugins or similar) to offload media (images mostly) in wordpress to an external service? like flicker, or imageshak? I think that offloading images from the wordpress installation increase significantly the mante the maintainability of your site, and not mentioning the speeding up of the backup...
You can check out the following plugins that use an external storage for media. Some of them supposedly use the build in media (S3), while other simply allow you to use the storage in your post (azure) via a button. http://wordpress.org/extend/plugins/windows-azure-storage/ , yes Microsoft wrote this plugin. http://wor...
offload media to external services
wordpress
I am using this code to show a list of all categories in sidebar <code> &lt;?php wp_list_cats('list=0&amp;sort_column=name&amp;optioncount=0&amp;hierarchical=0&amp;optioncount=1&amp;children=0'); ?&gt; </code> but the problem is that is lists the child categories as well. so the final result using the above code is lik...
<code> wp_list_cats </code> is deprecated. You should switch to the "newer" version <code> wp_list_categories </code> which also supports some additional options. For example the <code> depth </code> option, which is probably what you're looking for. See the WordPress codex for more information. <code> wp_list_categori...
How to hide child categories from displaying
wordpress
I'm working on a theme for a magazine publisher who routinely deals with a large number of images. I need them to be able to associate each image with a contributor (photographer, illustrator, artist, etc.) Each contributor is contained in a custom post type, 'jdp_contributors' and the contributor type is a custom taxo...
I'm not entirely sure why the get_posts() function works instead of creating a new instance of WP_QUERY. From what I understand about how WordPress queries work, get_posts() is actually creating it's own instance of WP_QUERY anyhow. Either way, here is the solution that I'm using currently. <code> &lt;?php //GET THE PH...
Loop issues when creating custom query for media uploader
wordpress
I have a series of day slots per location, in a multicheckbox custom field. I have a search page where the user can select location, weekday desired, and activity type. Right now I just have 2 samples: a class that meets on Tuesdays and one that does not. When searching for a Tuesday class, however, both are showing up...
i'm not sure about this one, but i think you have too many nested arrays. you should be getting something like <code> [meta_query] =&gt; Array ( [relation] =&gt; OR [0] =&gt; Array ( [key] =&gt; _cmb_tuesday_location_1 [value] =&gt; huntley [compare] =&gt; LIKE ) [1] =&gt; Array ( [key] =&gt; _cmb_tuesday_location_2 [v...
meta_query returning excluded result
wordpress
I created a custom post type and i want to display some text on the editor page below the title and above the text editor. How can i do this? I tried using add_meta_box, but i wasn't able to move it above the editor.
The best way would be using JavaScript to inject the element. Here's the gist of the markup for that page: <code> &lt;div id="poststuff"&gt; &lt;div id="post-body" class="metabox-holder columns-2"&gt; &lt;div id="post-body-content"&gt; &lt;div id="titlediv"&gt; ... other stuff ... &lt;/div&gt; &lt;div id="postdivrich" ...
How can i add some static text above the editor?
wordpress
I have made a login form on the front-end of my site using <code> wp_login_form() </code> . However, when the user types in an incorrect username/password they are redirected to the wp-admin login form. How can you instead display any error messages above the login form? Ideally, I don't want the user to ever have to s...
Here is what I did for anyone who has the same problem... You can use the <code> wp_login_failed </code> hook as mentioned stackexchange-url ("here"), however this won't work if the user clicks login without entering a username and password. To cover all errors you can copy the <code> wp_authenticate() </code> function...
Prevent wp_login_form() from redirecting to wp-admin when there are errors
wordpress
I am unable to get the Parent Taxonomy Terms here is the code i am writing <code> $myterms = get_terms( 'iqvis_event_category', array( 'parent' =&gt; 0 ) ); echo '&lt;pre&gt;'; print_r($myterms); echo '&lt;/pre&gt;'; </code> What is the Reason is there any Syntax problem ? or the parent argument is not working?? becaus...
I figured it out I just have to add another argument and then it was working fine: <code> $myterms = get_terms( 'iqvis_event_category', array( 'parent' =&gt; 0, 'hide_empty' =&gt; 0 ) ); echo '&lt;pre&gt;'; print_r($myterms); echo '&lt;/pre&gt;'; </code>
Unable to get the Parent Custom Taxonomy Terms
wordpress
I'm using the » Free e-commerce Theme Balita «, as posted on Smashing Magazine. It's great, but doesn't have the standard WP blog with corresponding number of post per homepage as settings; as default Twenty Eleven. Q: How do I manually add the blog to appear at homepage?
It looks like the theme is widgetized, and it actually has listed as a feature "Blog integration" - see here . Are you sure in the theme settings there are not options related to showing blog posts in one of the widget areas? The other place to look is "Appearance » Widgets". There may be a built-in Widget to display r...
Add Blog to WP homepage Manually
wordpress
can anyone advise what i'm doing wrong here? I'm trying to load a jQuery function IF the page isn't using a template OR if it's not a single OR if it's not an archive. I have the below... <code> &lt;?php if ( ! is_page_template('modelPages.php') || ! is_archive() || ! is_single ) { ?&gt; </code> But it doesn't seem to ...
try this <code> &lt;?php if ( (! is_page_template('modelPages.php')) || (! is_archive()) || (! is_single) ) { ?&gt; </code> Think your 'not' ! is causing the issue. btw, you could move it to this <code> &lt;?php if ( !( is_page_template('modelPages.php') || is_archive() || is_single() ) ) { ?&gt; </code>
Or operators in PHP
wordpress
My client have a site : business.com All the files of the old fashion site is there, images, video, html, css. i just made a folder called business.com/cms and installed wordpress here. FOr 2 month they write stuff, upload images and do there site in wp. Now it's time to lunch the site The problem, all the images and p...
Your easiest solution here is to keep everything in your cms folder. and follow this step found at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory This will keep all wordpress related files in the cms folder, but it will look like its running from the root, copy of index and some .htaccess wizardly as you...
Wordpress installation site folder move to the final site destination
wordpress
I'm modding a theme to use parent taxonomy terms instead of all taxonomy terms, now I've been able to only display the parents, but now I've run into a count problem. Basicly this is the code that has to be changed <code> $_products_in_term = get_objects_in_term( $term-&gt;term_id, $taxonomy ); </code> This gets all th...
<code> $terms = get_term_children( $term-&gt;term_id , $taxonomy ); $term_array=array(); foreach($terms as $terms){ $term_array[]= $terms; } $_products_in_term = get_objects_in_term( $term_array, $taxonomy ); </code>
How to get terms of not only the current cat but also of all its children
wordpress
I have problems with wordpress menu level classes. <code> &lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'primary' ) ); ?&gt; </code> this is the code i used to generate my menu, First level menu id is ul id="menu-home" second level class is ul class="sub-menu" but my third level menu also has same class as second...
This will add class <code> sub-menu-0 </code> , <code> sub-menu-1 </code> and so on depending upon their depth. <code> //This will go in functions.php file class wpse61220_submenu_class extends Walker_Nav_Menu { function start_lvl(&amp;$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent&lt;ul c...
Change the class of wordpress menu
wordpress
I have a site with different custom post types, I have two "index pages" for each one of these (where I query the posts and show) and also I include a search form on both of them. So the thing is that search forms goes by default to the search.php template, to filter search and show results only for that custom post ty...
So I have found the solution, I leave it here if anyone needs something like this in the future. On your search form add a hidden field: <code> &lt;input type="hidden" name="post_type" value="post_type_name" /&gt; </code> Then on your search.php file add the following WITHIN the loop: <code> &lt;?php if(isset($_GET['po...
Have different search results template depending of custom post type searched
wordpress
I noticed something when I var_dump(); on a single page in wordpress. Its not linked to its archive page at all or any parents. Is it at all possible to get the single pages archive information as if it were a parent page?
To get the archive link of a post type use <code> get_post_type_archive_link() </code> : <code> print get_post_type_archive_link( get_post_type( $GLOBALS['post']-&gt;ID ) ); </code>
Get single posts archive information
wordpress
I use custom menus with drop down. I want to make two different drop-down menus each with different styling. Wordpress puts drop-down items in a single ul with <code> class="sub-menu" </code> . But I need different class for each menu. <code> &lt;ul&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li&gt;Item 2&lt;/li&gt; &lt;li&gt;...
if you don't want to use a custom menu walker, you can use the classes wp already puts out. If you add a class to the menu item you know will have a extra <code> ul </code> , you'll have something like this <code> &lt;ul&gt; &lt;li class="menu-item menu-item-1"&gt;Item 1&lt;/li&gt; &lt;li class="menu-item menu-item-2"&...
Change sub-menu css class
wordpress