question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
By default, I have a 2m limit of uploads. I want to decrease this number. I found out that this code: <code> function custom_file_max_upload_size( $file ) { $size = $file['size']; if ( $size &gt; 1000 * 1024 ) { $file['error'] = __( 'ERROR: you cannot upload files larger than 1M', 'textdomain' ); } return $file; } add_...
That number is taken from <code> wp_max_upload_size() </code> , and there is a filter: <code> 'upload_size_limit' </code> . See <code> wp-admin/includes/template.php </code> . So this should work (not tested): <code> add_filter( 'upload_size_limit', 'wpse_70754_change_upload_size' ); function wpse_70754_change_upload_s...
Decrease file size upload in Media
wordpress
UPDATE: For anyone following this thread, the plugin solution does work, but seems to have a problem on my multisite format. I have now tested on 3 individual installs and on 3 multisites. On the multisites, the red "undeletable" marker appears next to the categories in the array, but they can get deleted. This may wel...
Extending @Roman's answer. The following was developed and tested in a Multisite environment - local and live WP installs. Looking at the source of <code> wp_delete_term </code> , there are some hooks that are triggered when the function is called. I'm not sure if this is the best way of doing this, but it works. <code...
Multisite - Protect categories from deletion?
wordpress
I've been sitting on this for three days and I still haven't figured out a good way to solve this problem—that's why i want to ask a community about it. I'm creating a page, which will have some historical routes in my city. I therefor need to create a custom post-type, which will be the route. Route have points. Each ...
If Points have such a complex structure then shouldn't you think of it as another custom post type, and associate them to a Route (or to several Routes)? that way you could have a Point in different Routes, which could be a reasonable expectation.
I need help in designing a custom post type
wordpress
Is there a way to remove the post title? or atleast not require me to enter a post title. I have migrated from tumblr to wordpress and I didn't need to have a title with tumblr so I was wondering if I could do the same with wordpress?
Wordpress does not require entering post titles, at least not in the backend. You can leave that part of the form blank. As far as your theme is concerned, that will depend on the theme author and whether they've considered someone not entering a title. The default twentyeleven theme handles it fine, linking to the pos...
Remove post title
wordpress
I'm using Contact Form 7 for my forms and also qTranslate to translate my website. I would like to translate all my fields and for that I used: <code> &lt;!--:en--&gt;First Name (required)&lt;!--:--&gt;&lt;!--:ru--&gt;Фамилия (обязательно)&lt;!--:--&gt; </code> But it display this: <code> First Name (required)Фамилия (...
What I normally do when using this combination of plugins is to create one form per language. Easy and effective. You could also try qTranslate quicktags : <code> [:en]English text[:ru]Фамилия </code> . But much probably this will lead to some issues down the road.
How to Translate Contact Form 7 using qTranslate?
wordpress
Is there a way to make all files (also in subfolder) in my theme directory visible in the theme editor? I need a way to edit themes without having to upload a new one every time. Thanks!
I think, this is not possible in the current version, is a old ticket in the trac. But you can add a other editor via plugin and it works, like WPide
Make theme editor to show all theme's files
wordpress
How do I rewrite the <code> if (have_posts()) : ... while (have_posts()) : the_post(); </code> style Wordpress loop below as a new_query style-loop using <code> &lt;?php $the_query = new WP_Query(); </code> ? ( As shown in http://codex.wordpress.org/Class_Reference/WP_Query ) The current loop below alternates post clas...
You're 95% of the way there already. Just add <code> if ( $my_query-&gt;have_posts() ) </code> and incorporate your <code> $odd </code> variable: <code> &lt;?php $my_query = new WP_Query('offset=5&amp;showposts=10'); if ( $my_query-&gt;have_posts() ) : $odd = false; while ($my_query-&gt;have_posts()) : $my_query-&gt;th...
How do I rewrite this loop as a new WP_Query style-loop?
wordpress
I started using this functions for my "search results"-page. <code> #SearchRewrite add_action('generate_rewrite_rules', 'my_rewrite_rules'); function my_rewrite_rules( $wp_rewrite ) { //RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L] $new_rules = array( 'icerik/(.+).html' =&gt; 'index.php?s=' . $wp_rewrite-&gt;preg_...
Fatih, Use str_replace for Turkish chars issue. Change code like this; /* Plugin Name: Redirect Search Results Author: Abdussamad Plugin URI: stackexchange-url redirect_search_results { function __construct() { add_action( 'init', array( $this, 'redirect' ) ); } function redirect() { if( isset( $_GET[ 's' ] ) ) { $turk...
Search url wp-rewrite after redirect?
wordpress
Please note this is all "working" - the question is about the best practice and to try and work out why I need to include the PHP file which contains the class in two places for it to work correctly. I'm working on a simple parent theme to speed up my own development cycle - and have got to the point of testing a simpl...
Handle all the class loading in your parent theme on a predictable action (point in time) and hook in later in your child theme. Example: <code> add_action( 'wp_loaded', 'parent_prefix_load_classes', 10 ); function parent_prefix_load_classes() { $classes = array ( 'Extra_Comment_Walker', 'Extra_Nav_Menu_Walker ); forea...
Declaring an instance of class included in parent theme from child theme functions.php
wordpress
I use <code> get_posts ($arg); </code> to query the post table. Usually I need only three fields: post_title, ID and post_excerpt. But the data returned are many more, including post_content that is usually huge. I know I can use <code> 'fields' =&gt; 'ids' </code> to get only the ID. But I would like to use <code> 'fi...
<code> get_posts() </code> uses the <code> WP_Query </code> class to fetch posts. Usually, it returns an array of post objects. The <code> $fields </code> parameter for <code> WP_Query </code> accepts two valid arguments: <code> 'ids' </code> will make it return an array of post IDs and <code> 'id=&gt;parent' </code> w...
How to optimize my query filtering out unwanted data?
wordpress
I see plenty of tutorials for much older versions of WP online, but cannot find one for 3.4.2 to separate comment content and the author's avatar/gravatar. I'm seeking a code that separates the actual comments content from the gravatar and does so in the simplest way possible , I'd rather not update comments.php every ...
Ok, so this is what I've done. If anybody has a better idea I will leave the answer open for a few hours and choose it! <code> &lt;?php if($comments) : ?&gt; &lt;ol&gt; &lt;?php foreach($comments as $comment) : ?&gt; &lt;li id="comment-&lt;?php comment_ID(); ?&gt;"&gt; &lt;?php if ($comment-&gt;comment_approved == '0')...
How do I separate author avatars and comments in 3.4.2?
wordpress
I am using this function to limit the content in my themes. But the problem is whenever I call the function, it also displays the image caption. I want to remove the image caption when calling the_content_limit function. Here is the code: <code> function the_content_limit($max_char, $more_link_text = '', $stripteaser =...
Image captions in Wordpress are actually shortcodes. Shortcodes are applied by the filter: $content = apply_filters('the_content', $content); For example, Wordpress creates the following code in your content when you enter an image caption: [caption id="attachment_55" align="alignleft" width="127" caption="Here is my c...
How to limit post content and remove image caption from it
wordpress
I need to know if it is safe to use <code> user_activation_key </code> (from <code> WP_User </code> ) for other purpose like email verification (a functionality that I would be creating that would send an email verification first before activating the account created)? So here's how things will work. A user will regist...
Do you think this will be safe? Maybe. Two issues. You also need to make sure the key isn't guessable. No incrementing numbers. You can use something like <code> wp_generate_password </code> to get some psuedo random characters. Use a random "salt" plus the user's email and sign up time or <code> uniqid </code> and you...
Use the user_activation_key for other purposes
wordpress
I am trying to create a custom Rewrite URL something like <code> function add_my_rule() { global $wp; $wp-&gt;add_query_var('state'); $wp-&gt;add_query_var('state_destination'); add_rewrite_rule('destination/([0-9]+)/([^/]*)/page/([0-9]+)','index.php?pagename=destination&amp;state=$matches[1]&amp;state_destination=$mat...
this is a nice little re-write class created by: Author Kyle E Gentile I found this a while back which works a treat in most plugins I've created... Save the first section of code in a file called: add_rewrite_rules.php <code> &lt;?php /* //Author Kyle E Gentile //To use this class you must first include the file. //Af...
Custom rewrite rule is not picked by Wordpress
wordpress
My Wordpress site is having a bad URL structure when I'm adding new URL. For example in comments, when commentators fill in their website, it always has this structure <code> http://mysite.com/www.commentorsite.com/ </code> . The same thing happens in my side bar widget. When I add new text widget and put something lik...
You need to start your links with <code> http:// </code> Examples: The link <code> facebook.com/mypage </code> becomes <code> http://facebook.com/mypage </code> The link <code> www.commentorsite.com/ </code> becomes <code> http://www.commentorsite.com/ </code> This will stop the links becoming <code> http://mysite.com/...
Site URL always in front of other URLs
wordpress
I have a custom loop to show posts that meet a certain set of $args like this: <code> &lt;?php $recent = new WP_Query( $orderargs ); while($recent-&gt;have_posts()) : $recent-&gt;the_post();?&gt; </code> This works great when the $orderargs bring up posts, but in some situations, there will be no posts, and I want to s...
You do that the same way like with regular posts: <code> if ( $recent-&gt;have_posts() ) { while($recent-&gt;have_posts()) { $recent-&gt;the_post(); // print posts } } else { print 'no posts found'; } </code>
Show default content if custom WP_Query has no posts
wordpress
I'm developing a multisite and creating my own themes for it. All the themes will feature some standard pre-defined pages eg. homepage, about, blog, contact us etc. Each page will also have a number of page template options available, eg: homepage1, homepage2, blog 1, blog 2, contact. The problem is that some of the pa...
The short answer: there isn't a way to control what shows up in that dropdown list, there are no filters available for it. Hopefully that will change in a future version. A possible solution would be to create your own meta box that lists templates from your own array of templates appropriate for the current page, and ...
Limit page template choice by page title or ID?
wordpress
I am looking to create a behavior as shown in the following link: http://www.javaexperience.com/java-role-of-serialversionuid-in-serialization/ Here all posts from the same category are being displayed. Currently, it is handwritten HTML code, I want to mimic this behavior using PHP code in my single.php. Following is t...
try this ; <code> $cat = get_query_var('cat'); $PozCat = get_category ($cat); $PozCat-&gt;id // give to us current cat id. </code> Than use this hook in your query ; <code> &lt;ul&gt; &lt;?php $cat = get_query_var('cat'); $PozCat = get_category ($cat); //$PozCat-&gt;id query_posts('posts_per_page=-1&amp;cat='.$PozCat-&...
Display all posts in current category
wordpress
WordPress database error: [MySQL server has gone away] I did not make any changes, and the host says that there is no problem with MySQL. Can anyone explain what the error means? and how to troubleshoot? This is a shared hosting environment, and no recent changes where made to the site. Also other wordpress sites are e...
This is not a WordPress error, it is from MySQL : The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. Talk with your host again.
What does this error mean? WordPress database error: [MySQL server has gone away]
wordpress
My site has been working perfectly in all browsers, until suddenly 2 days ago. Now in Chrome and Firefox, the main page accordion slider is stuck, the "log in" button is not functional, and a few other things. I have tried the site in Safari, Opera, Internet explorer and it still looks and operates as it should. I have...
It looks like a javascript error is preventing scripts from running. There error is from the script cloudflare.min.js, so perhaps it has to do with how you have Cloud Flare setup? Did you just recently start using it? In particular it seems to want to load a non-existent image from 'http://www.fearlessblue.com/trueblue...
Certain aspects of site suddenly not working in Chrome and Firefox
wordpress
I have an old website that I'm revamping with a custom new Wordpress theme. The old site had a custom (non-WP based) downloads archive that mapped URLs like this: <code> /downloads/view.php?id=2 </code> The ID maps to a download item in a separate MySQL database. I'd like to move everything over to Wordpress in this re...
I ended up solving the issue by hooking onto the " <code> template_redirect </code> " action. After that, I check if the page <code> is_404() </code> and then check if the URL matches my pattern. I set the appropriate header ( <code> 301 </code> versus the <code> 404 </code> that normally would be triggered) and perfor...
Redirect Old .php URLs to New Wordpress Page
wordpress
I'm working on some themes for a multisite and would like to modify the code below. It relates to a special div that will display an image or logo that users upload. Normally the logo links to the home page of the blog, but could it be modified so that if the user is logged in it will link to "/themes.php?page=wptuts-s...
Change the line with the URL: <code> &lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;&lt;div id="logo"&gt; </code> … and check if the user is logged in: <code> &lt;a href="&lt;?php if ( is_user_logged_in() ) { echo admin_url( '/themes.php?page=wptuts-settings' ); } else { echo home_url( '/' ); } ?&gt;/"&gt;&lt...
Change a url / link if a user is logged in?
wordpress
Right now for my plugin, I am using <code> in_admin() </code> to determine if the user is in the frontend of the site or in the admin area. However, the problem occurs when plugins use <code> admin_ajax.php </code> to process ajax requests. I need a way to register hooks and plugins only when processing <code> admin_aj...
Check the constant <code> DOING_AJAX </code> . Its definition is the first working code in <code> wp-admin/admin-ajax.php </code> . Example: <code> if ( defined( 'DOING_AJAX' ) &amp;&amp; DOING_AJAX ) { // do something } </code>
How to check if I am in admin_ajax?
wordpress
Personal blog with occasional guest authors (non-commercial) self hosted Wordpress. I create a bespoke author PHP file for each author ( example ). I use Yoast SEO and set a default image for meta property='og:image' where one isn't specified for a post or page for sharing to Facebook / Google+, etc. Is there any way I...
Try copying the following code into your functions.php file. It adds a custom og:image property for the authors with nicenames of <code> michelle-robinson </code> , <code> mystery-man </code> , <code> john-smith </code> , and a default fallback image, respectively. You can easily change this to suit your needs. add_act...
Featured image for social sharing ot author archive page
wordpress
I'm running the latest version of WordPress with pretty permalinks enabled. I'm looking for a way to include the Post Format type (eg: link, status, quote) in the post's permalink. When the post has no format assigned, or uses the 'standard' format, I want that part of the permalink to empty. Example using the link pos...
While researching this topic myself, I found a plugin called Post Format Permalink . However, this plugin is not compatible with recent versions of WordPress; it is also filled with unnecessary code. I forked the plugin's repository on GitHub, and improved the code greatly. I can now use a <code> %post_format% </code> ...
Include Post Format in permalink
wordpress
I have a landing page that pulls in an excerpt, title and thumbnail of its children. It works, except the title (which is the page title) link is doubling up the parent folder in the url it creates. like this: www.site.com/restaurant/restaurant/mcdonalds. I'm not great at PHP and I can't figure out why it's doubling on...
if you look into the html in the browser, you should see that the function is outputting a relative link uri; is there any reason why you are trying to use <code> get_page_uri() </code> instead of <code> get_permalink() </code> ?
parent page grabbing wrong url for child pages - get_page_uri($pageChild)
wordpress
I added a new custom post type to my Wordpress theme but it refuses to show on the homepage. I tried setting <code> &lt;?php query_posts( array( 'post_type' =&gt; array('post', 'reviews') ) );?&gt; </code> but it doesn't seem to work, it just loops my normal posts. Any suggestions would be greatly helpful. Here's a pas...
I would avoid the use of query_posts -- it forces another database hit. There are plenty of other ways to hook in and change the query before posts are fetches. <code> pre_get_posts </code> is one of them. To display multiple post types on the home page (pages and posts in this example): <code> &lt;?php add_action('pre...
Displaying custom post type on front page
wordpress
I am creating a website so that users can submit their articles from the front end. I have quite a few things set up: The ability to submit custom post types from the front end Blocked from the back-end. I'd like to create a page (for logged in users) labeled "my posts" or my "submissions" that will show logged in user...
I have Something that i use from time to time when i need something like that: <code> &lt;?php /* Plugin Name: List User Posts Plugin URI: http://en.bainternet.info Description: lists user posts on the front end Version: 0.1 Author: Bainternet Author URI: http://en.bainternet.info */ if (!class_exists('list_user_posts'...
Frontend editing, Frontend user dashboard
wordpress
Usually I google but I couldn't find an answer for my problem. Most entrys I found were dealing with adding extra featured image sizes, but not when it comes to having different featured image sizes displayed on the index site embeddeed within a custom div with an option to choose from. What I try to do is working with...
It looks like you want a magazine theme. The way I do this is with multiple loops. Each loop requests a number of posts, and displays them with a certain size thumbnail, a certain size headline, and maybe an excerpt. Then a new loop starts. The site fashioncow.com uses 4 loops on the home page. The loop first loads thr...
Multiple featured sizes / images / excerpts
wordpress
Is it possible to display the custom field/meta data content with some html? Usually i would use the following to just display the content... <code> &lt;?php echo get_post_meta($post-&gt;ID, '_cmb__description',true);?&gt; </code> However, when there is actually meta content i want it to appear within some html, but i ...
Yes, just check if you got something back from the post meta: <code> $value = get_post_meta($post-&gt;ID, '_cmb__description',true); if ( $value ) echo "&lt;div class='box'&gt;$value&lt;/div&gt;"; </code>
Display Meta Data with HTML?
wordpress
I'm creating custom files in a plugin and adding them to the Media Library using the code provided in the Wordpress Codex for wp_insert_attachment. However, my plugin occasionally overwrites those files. I need to make sure that the files are not added again to the Media Library. Here is the current code: <code> $wp_fi...
<code> global $wpdb; $image_src = $wp_upload_dir['baseurl'] . '/' . _wp_relative_upload_path( $filename ); $query = "SELECT COUNT(*) FROM {$wpdb-&gt;posts} WHERE guid='$image_src'"; $count = $wpdb-&gt;get_var($query); </code> You can use this at the top of your code. Then check the value of <code> $count </code> . If i...
Checking if a file is already in the Media Library
wordpress
I am having issues with using custom post types and custom user roles. I created a custom post type called Businesses. Then I created capabilities for users of a certain type to be able to add and edit business listings. The problem I am having is when I create the user type and add the capabilities of edit_business, e...
So I figured out the problem here. When you use the members plugin and create roles for custom post types you need to create a function which maps out your meta capabilities. http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types
Custom post type & role issues
wordpress
I have a custom taxonomy term of 'artists' which is the artist's last name and a custom field of 'first_name'. To create a list all all artists with both their first name and last name I am using the following code, but it is printing as two separate lists. Do I have to join tables (never done this) to accomplish this ...
Replace <code> the_field </code> with <code> get_field </code> . The former echoes data without the need to explicitly call <code> echo </code> on the function name, the latter returns data, which is what you need when storing data against a variable for later use in your function. In your case, concatenating the first...
How to add contents of a custom field to a taxonomy term list?
wordpress
I'm using the built in menu system, and I wan't to change the text of the home menu link to something else, like "hjem", and i have tried placing this in the code: <code> &lt;?php wp_page_menu( array( 'show_home' =&gt; 'Hjem', 'sort_column' =&gt; 'menu_order' ) ); ?&gt; </code> But that did nothing but show the menu, w...
Funnily enough, I see the same behavior in WordPress 3.4.2 and 3.5-beta2. No plugins active, theme TwentyEleven. Even setting <code> show_home </code> as <code> false </code> will show the Home button ?! Checking the core, I see this filter that does the trick: <code> add_filter( 'wp_page_menu_args', 'wpse_70551_change...
Change the menu home link to something else
wordpress
I searched for "title length" in questions but results were all about setting max length and limiting and.. What I want to do is to create an if-statement, to determine if the post title has more than 68 characters or not and if it had, add <code> smaller </code> class to it. I wrote the code like this: <code> &lt;?php...
<code> the_title() </code> echoes the result. Use <code> get_the_title() </code> to return the title.
Adding a class to post title considering the title length
wordpress
I'm confused by the template hierarchy in WordPress. I have <code> front-page.php </code> in a theme I'm developing. It looks great and it works, but then when a user clicks 'Older Posts', it just shows the same content as before, but the URL is changed to ?paged=2. Looking at the diagram about Template Hierarchy on Wo...
Pagination does not affect the template usually, <code> paged.php </code> is the exception but not of interest for your question. To style the first page differently than later pages check for <code> if ( is_front_page() and 1 &lt; get_query_var( 'paged' ) ) { // code for later pages } </code>
Can index.php take over for front-page.php in template hierarchy on second page?
wordpress
I have created several custom taxonomies and each "archive" can be viewed on the url mysite.com/taxonomy/term Is it possible to rewrite the URLs so my taxonomy archive lives under for example mysite.com/calendar/taxonomy/term instead?
When creating a custom post type you can define the slug using the argument "rewrite" http://codex.wordpress.org/Function_Reference/register_post_type or you could use a plugin http://wordpress.org/extend/plugins/custom-post-type-permalinks/
Rewrite URL for taxonomy listing
wordpress
I'm using a custom meta box to output a list of post IDs within a particular post type ("Publications" in this example). Is there a way I can output this array into a custom loop to only show posts with those ID's? This is the code I am using; Meta box array <code> $related = get_post_meta( get_the_ID(), 'ps_related-pu...
You're looking for <code> post__in </code> &amp; <code> post__not_in </code> parameters http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters Both of them are an array of ID's for the post's to include or exclude in the results BTW in your code, you had a semicolon just after your foreach
Exclude posts based on an array
wordpress
I need to display post details by ID on front page template ( <code> front-page.php </code> ). On the front page I want to display the post’s title, excerpt &amp; featured image. I have tried to do that but no idea on how I should be doing that. Is there any function in WordPress that can be used to do it?
You can use <code> get_post </code> for that Example: <code> &lt;?php $post = get_post($id); //assuming $id has been initialized setup_postdata($post); // display the post here the_title(); the_excerpt(); the_post_thumbnail(); wp_reset_postdata(); ?&gt; </code>
Display post details by post ID
wordpress
Is there any way I can get the menu link for admins? http://codex.wordpress.org/Function_Reference/edit_post_link Similarly to the <code> edit_post_link() </code> that returns the edit link for loggedin Admins I would like to do something similar for the <code> edit menu </code> if there is anything like that?
You can use <code> admin_url('nav-menus.php'); </code> This function can be used to get url's for any admin screen, please check out the codex for more information http://codex.wordpress.org/Function_Reference/admin_url
Get admin menu link
wordpress
Quite a broad question but I was wondering if it's possible to remove user management from WordPress and let it be handled by a remote database? I have an existing user table with everything I need and I wish to keep all my users there. Is it possible for WordPress to somewhat ignore it's own user table and use mine in...
$wpdb is a global variable for the database class. In it <code> $wpdb-&gt;users </code> points to the name of the users table. As long as it's the same database, you can use this to change the name of the table but it might create errors if the schema doesn't match. Another way is to extend the <code> wpdb </code> clas...
Using my own user table
wordpress
I am trying to figure out the best way to do this with Wordpress. I want to show a feed of news items on my site - the items are pulled from an external RSS feed. If an item is clicked, I want to show the contents of that specific item on a page within my own site. Looking at the contents of the external feed I am acce...
Displaying feeds usually links out of your site to the rest of the original content. You will have to use feeds that display all the content (or enough to show on your own pages) and then pass that information to a page using a template that can receive and display it. An alternative is to just pass some unique identif...
RSS feed - get specific item from external feed
wordpress
I'm wanting to allow users to register to my wordpress site. What is the best and safest way to implement this? The ultimate goal is to give the users the option to subscribe to alerts when updates are made to the site. Thanks,
The easiest way is to make sure you have the following settings under <code> Settings &gt; General </code> . Under the Membership settings make sure <code> Anyone can register </code> is checked and <code> New User Default Role </code> is set to subscriber. This will allow people to register at <code> example.com/wp-lo...
what is the best and safest way to allow users to register to site
wordpress
I have a custom application with thousands of users who already have a password stored. I would like to set up a self hosted wordpress site to accompany that application and to use the usernames and encrypted passwords that already exist in that database. Is there a way to configure Wordpress to not use the normal list...
Investigating the filter <code> authenticate </code> , we can find that it is called inside the function <code> wp_authenticate </code> , which is a pluggable function . That means that it can be replaced by one of our own making. This is the original function , plus a marked entry point: <code> function wp_authenticat...
Replacing the Wordpress password validation
wordpress
i am building a job system which will store following data: job title - post title description - content location - post meta / taxonomy sector (it/sales &amp; etc)- custom taxonomy salary start - post meta salary end - post meta contact person - post meta skills - post meta and etc so far i created a custom post type ...
When the question comes to what to use <code> Post Type, Taxonomies, custom fields ? </code> I find that the understanding what each one of them stands for helps make the selection easier so i use: Post types - for all major data records that need/not to be displayed or queried. Taxonomies - for grouping posts/custom r...
best way to use custom taxonomy, post type and meta in a job system
wordpress
A project I inherited had a dozen custom post types. Trouble is, they all come off the admin menu sidebar separately. It's not very tidy. Is there a plugin where I can make these subitems of a parent menu, or is there a way, programmatically, I can edit my theme's functions.php to make it make these as submenus?
On the function to register a new custom post type can you set this CPT as Submenu to a exist menu item. Use the param <code> show_in_menu </code> A example: <code> register_post_type( 'issue', apply_filters( 'wpit_register_issue_post_type', array( 'labels' =&gt; $issue_labels, 'rewrite' =&gt; $issue_rewrite, 'supports...
How Do I Programmatically Better Organize Custom Post Type Menus?
wordpress
I'm trying to grab all image id's that are associated with the [gallery] shortcode that are listed as exclude. For example: if my post has <code> [gallery exclude="1,2,3"] </code> I'd like to get a variable that would echo like this <code> echo $excludes; </code> result <code> 1,2,3 </code> thank you for any help you c...
It took me a while to find a solution that worked for me, but since all I was looking for was the delimited list of attachment id's associated with a certain attribute like <code> exclude </code> or <code> hide </code> , this worked for me: <code> # Grab the list of "hide" attribute $regex_pattern = get_shortcode_regex...
get attributes/part of the gallery shortcode
wordpress
I have set a field to autocomplete/autosuggest but the drop down isn't appearing as I type. I can see the admin-ajax.php requests and the data returned in the Network tab of Chrome Developer Tools so that appears to be retrieving the suggestions fine. I'm not real sure how to troubleshoot this further, and sort the iss...
I would use <code> .ajax() </code> instead of <code> .suggest() </code> in your jQuery. <code> jQuery.ajax({ type : "post", url : myAjax.ajaxurl, data : { action: 'se_lookup', }, success: function( result ) { console.log(result); } }); </code> You should now receive the values back from the SQL.
jQuery drop down not appearing for autocomplete/autosuggest
wordpress
I have theme A currently active, and theme A has custom settings (like header image, custom CSS, etc). I am having issues with theme A, and want to activate theme B while I troubleshoot these issues. If I activate theme B, and go to activate theme A later, will my custom settings be preserved?
Yes, your options should be preserved unless your themes are really bad and doing it wrong.
Will activating a different theme preserve custom settings to current theme?
wordpress
I am importing some css files in another css document like so, however the foundation.css file is getting a 403 for the stylesheet when I visit the location, my ftp says it is there and it all works locally. The site is live here username:anders pass:reading61 I am not sure what is going on. <code> /* Theme Name: git.A...
403 Forbidden is a permissions error, check that the file has proper permissions for public access on your server.
css file status 403
wordpress
I'm setting up a website which will track the users by their role in relationship to the company. I want to use the built-in WP user functionality, but I don't want to send out notifications to all these people that I'm mucking around with the backend, when I have no intention of giving them edit access at all. I just ...
Maybe the simplest way is to make a quick plugin that has your own form for inserting users. <code> wp_insert_user() </code> doesn't require an email address or password, and doesn't generate an email notification. <code> function wpa70409_add_user(){ $userdata = array( 'user_login' =&gt; 'testuser', 'display_name' =&g...
Is there any way to not require email address or disable notification upon setting up a member?
wordpress
I was reading this post: stackexchange-url ("When should you use WP_Query vs query_posts() vs get_posts()?"), which seems to have become the go-to post for understanding the difference between the different functions for making custom loops. In the article, it says that [get_posts] doesn't modify global variables and i...
<code> get_posts </code> doesn't modify global variables &amp; is safe to use anywhere but <code> setup_postdata </code> does modify the global variables. Use the function <code> wp_reset_postdata() </code> just after the foreach loop. It reverses the changes made by <code> setup_postdata </code> . The thing it does is...
get_posts() and global variables
wordpress
I'm currently using the simple-fields plugin to add an event start date field that is a <code> date </code> type field to a custom post type called an 'event'. On my homepage I'm looking to display the three closest events to today's date that haven't passed today's date. I currently have: <code> $recent_events = new W...
As Milo says, Simple Fields currently stores the dates in a much non preferred way. I can think of two ways to solve this right now: One: Fetch the posts "manually" using sql and use mysql function substr to re-make the dates to a valid format that you can sort on. A bit cumbersome, but would work. The SQL query would ...
Custom query object with Simple-Fields custom date field
wordpress
Here is the my custom query ; <code> &lt;?php $Poz = new WP_Query(array( 'posts_per_page' =&gt; 3, 'orderby' =&gt; 'date', 'order' =&gt; 'DESC', 'no_found_rows' =&gt; true, 'update_post_term_cache' =&gt; false, 'update_post_meta_cache' =&gt; false, )); // The Query $the_query = new WP_Query( $Poz ); // The Loop while (...
Yeah, use <code> 'nopaging' =&gt; true </code> http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters <code> $Poz = array( 'posts_per_page' =&gt; 3, 'orderby' =&gt; 'date', 'order' =&gt; 'DESC', 'update_post_term_cache' =&gt; false, 'update_post_meta_cache' =&gt; false, 'nopaging' =&gt; true, ); $the...
posts_per_page doesnt work
wordpress
I have a function set up and working based off the discussion in this thread: stackexchange-url ("Custom taxonomy, get_the_terms, listing in order of parent &gt; child"). My version includes term links and allows me to display the term information in single.php in a fashion that looks like a breadcrumb. However, I have...
Alas no answers or comments! :P Not to worry, a colleague helped me out here and here is the above code working with an $exclude <code> function terms_by_order($taxonomy, $exclude) { global $post; $terms = get_the_terms($post-&gt;ID, $taxonomy); // check input if ( empty($terms) || is_wp_error($terms) || !is_array($ter...
Retrieving custom taxonomy in order, but excluding specific tax IDs
wordpress
Hmmm... maybe trickier than I hoped? If this is simply impossible then please do let me know :-) Question Refinement:How can I adapt the include section of this code to use category names instead of id's? Thanks <code> $dropdown = wp_dropdown_categories( array( 'include' =&gt; '58, 3', 'name' =&gt; 'category_id[]', 'hi...
Well after thinking about this some more, I've realised that it was a bit of a dumb question to ask... My problem is actually being able to pre-define categories in themes for new subsites of my mulitiste. I've got around this by using a premium plugin which allows me to offer blog templates / themes with a few predefi...
Restrict category choice in dropdown menu?
wordpress
I've searched already and couldn't find anything tailored to my specific problem, apologies if it has already been asked though. I have a public Wordpress install and a members only one on a subdomain. The reason for this is that they are both very different sites in terms of functionality so creating members only post...
if it's the same database, you can write the query easily using the global $wpdb variable. If it's a separate database, create another instance of wordpress wpdb class &amp; write the queries to it <code> $wpdb2 = new wpdb( $user, $pass, $db, $host ); </code> In any case, you'll need to know the database tables prefix ...
Pull posts from another wordpress install on same server
wordpress
I want to set up a function that notifies me when a core update is available. But i can't find any functions that check for updates. I have looked at list_core_updates() and it may be possible to check if it returns anything, but i don't know if that is smart.
There is <code> get_core_updates() </code> . Note that you might need to manually include admin file that declares it, if running in front end and such. Example use: <code> require_once ABSPATH . '/wp-admin/includes/update.php'; print_r( get_core_updates() ); </code> Example return: <code> Array ( [0] =&gt; stdClass Ob...
Find out if there is a available core update?
wordpress
My problem is the script is not registering in the footer it, is just disappearing, although the <code> jquery.js </code> does show up in the head. I have the following code in my theme's <code> functions.php </code> file: <code> function wptuts_scripts_with_jquery() { // Register the script like this for a theme: wp_r...
You need <code> wp_footer() </code> call in your footer, before closing <code> body </code> tag. Theme without it is pretty much considered broken, since things like footer scripts simply can't work without it.
Trying to register script in footer
wordpress
I'm trying to run custom sql for search results, and I'm having trouble limiting the filter to the main query without running a redundant query. I'm successfully getting results via the following: <code> add_filter( 'posts_request', 'my_request_filter' ); function my_request_filter($sql) { if(is_search()) { $sql = 'som...
The posts_request filter actually takes a second argument, which is the query. You can check if that query is the main query. Try this: <code> add_filter( 'posts_request', 'my_request_filter', 10, 2 ); function my_request_filter($sql, $query) { if($query-&gt;is_main_query() &amp;&amp; is_search()) { $sql = 'some custom...
how to restrict posts_request filter to the main query only
wordpress
I have a webservice and I want to sell it and allow the customer to set it up through a website. I'm thinking to use WordPress to make this website, but don't know if it is possible or how to do it. Basically, my webservice needs some information from the customer to work. I mean, after buying our service, the customer...
The answer is yes but you may need to use a combination of access plugins and custom post types to represent the data that your users are going to enter. Start with researching custom post types in the WP codex and then research some of the developing plugins to help speed up the process in the area - check out "podCMS...
Creating a full business website
wordpress
I am wondering if there is any reason why the following code would not work? My situation: I have a custom category set up called 'Issue'. What I want to do is get the most newly created category (which is 'Volume 2 Issue 1') and get its ID so that I can run the plugin function <code> z_taxonomy_image_url($currentID); ...
Removed the single quotes I had been adding to <code> $newtax </code> got it to work (as following:) <code> $taxonomy=wp_list_categories('taxonomy=issue&amp;echo=0&amp;number=1&amp;orderby=ID&amp;order=DESC&amp;show_count=0&amp;style=none&amp;title_li='); $tax = strip_tags($taxonomy); $newtax = trim($tax); $getID = get...
Get newest created custom category (get_term_by and variables) (outside Loop)
wordpress
I have a blog where all the posts had the post format Image . This morning I see that somehow they have all been changed to Aside . I'm still trying to figure out how this happened, but in the meantime, how do I go about changing them all back to Image? Is this something I can do with a SQL statement or do I need to wr...
You can do this right in interface: Select posts in need of change in admin post list screen Select <code> Edit </code> in <code> Bulk actions </code> dropdown and press <code> Apply </code> next to it Choose <code> Format </code> > <code> Image </code> in interface panel that appeared Press <code> Update </code> to ap...
How to change post format from Aside to Image for all posts?
wordpress
I have a blog on Blogger that I would like to turn into a bbPress forum. This is a blog that has essentially been used as a forum, so bbPress is a better solution. Unfortunately, by default bbPress only seems to be able to import from phpBB and bbPress. I imported Blogger into WordPress as posts thinking I might be abl...
No, there isn't. And unfortunately that's because you've been using Blogger to do something it was never intended to do. I'm not saying this is a bad thing. Blogger (and WordPress) are built to handle an article format: One author publishes a large article Other writers create short-format comments Comments and replies...
Is there a way to import Blogger into bbPress?
wordpress
I'm using Wordpress Options Theme and I'm getting an issue. Here's the code: <code> $options[] = array( "name" =&gt; __('Texto de bot&amp;oacute;n de enlace a cotizaci&amp;oacute;n',THEMENAME), "desc" =&gt; __('Inserta el texto que aparecer&amp;aacute; en los botones de cotizaci&amp;oacute;n',THEMENAME), "id" =&gt; "ns...
Values set in the 'std' key of the array, <code> 'std' =&gt; 'your default value' </code> Are saved to the database on first initialization of the framework. Once you overwrite the default value and or remove the default value, even if left as a blank field, the default no longer applies unless you hit the "restore def...
Wordpress Options-Theme STD (default) value does not work
wordpress
The main "Forums" page where all forums are supposed to be listed is empty. What have I missed here or the combination of BuddyPress and bbPress caused this page not to work anymore? I have followed the installation guide here http://codex.buddypress.org/getting-started/installing-group-and-sitewide-forums/
Ok, I figured it out In BuddyPress installation guide, it says I needed to delete "Forums" WordPress page so I did. Turn out that "Forums" page held on to mywebsite.com/forums permalink although it was already trashed. So I went into phpMyAdmin and change the slug of the page to forums1 and guid to mywebsite.com/forums...
Empty "Forums" page BuddyPress site wide forums - bbPress
wordpress
I am quite new to WordPress and PHP. I am currently working on a website and I finally come down to WordPress. I guess I might be able to accomplish my work on top of WordPress but I am not sure. I want to hear you opinion. My requirements: Users can register a blog in our site and publish their pages. Users can embed ...
Maybe you need to use the WordPress Network feature Documentation of interest: Don't Use WordPress Multisite Multisite Rationale WordPress Multisite 101 WordPress Multisite 110 EDIT: Some features of Wordpress Multisite based on my investigation: 1 Users can register a blog in your site and publish their pages. 2 Users...
Is it proper to build a site supporting blog visitors in WordPress?
wordpress
What are the critical files a theme MUST have to be a WordPress theme and validate properly?
http://codex.wordpress.org/Theme_Development#Template_File_Checklist The bare minimum required is your index.php file and style.CSS file. Those two files alone are technically enough to run your entire theme. It's highly unlikely that you'll rely on those two alone. The above link gives you an in-depth look at both the...
What are the critical theme files when building a custom theme?
wordpress
I've written several plugins using the structure : /plugins/myplugin/myplugin.php /plugins/myplugin/class/class-myclass.php So as to take advantage of OO and overall structuring my code From within the class file there are times I need to get the URL of the base plugin... I have been using the following, but I'm sure t...
In a subdirectory within your plugin directory you can use the following code: <code> $this-&gt;plugin_location = plugin_dir_url(dirname(__FILE__)); </code>
Get plugin_dir_url() from one level deep within plugin
wordpress
May be the question in title is not explaining what exactly I want. So I will explain one logic and then ask what problem I am getting from that. We are using wordpress. We have 2 categories Option1(Having 64 different values) and Option2(Having 8 different values). We wanted url like ourdomain/Option1/Option2 dependin...
WordPress has a function to send a different status header : <code> status_header( 200 ); </code> If you send that after WordPress has send its headers and before you print anything you will get a status header 200. You could also filter <code> 'status_header' </code> and change the value there. See <code> wp-includes/...
In wordpress I am manipulation 404 response. I want to give the response before 404 error is given to google
wordpress
I am trying to get posts with an author's ID as a meta value in the <code> author.php </code> template using additional request parameter. For example I want posts with john's ID as a meta value using a request like this <code> http://localhost:8888/twitgreen/author/john/?eco=somemetakey </code> So far I can make it us...
Alternative approach to answer the problem So far I havent found any method to do that. One would be better of creating a custom page for any custom query than modifying the author.php.
Query author's posts & posts that have author's id as meta value
wordpress
I'm making a one page site. On the page I want to run WP_Query three or four times to pull in those 3-4 pages. The page looks a bit like this: <code> &lt;div class="row"&gt; &lt;?php $args = array( 'pagename' =&gt; 'page-1'); $the_query = new WP_Query( $args ); // The Loop if ( $the_query-&gt;have_posts() ) : while ( $...
How-to simplify your life I'd go a fairly simpler route: Add a "main/parent" page Apply your template there Add "child" pages to this main page Alter the query to include them Code example as plugin for a quick test Here's an (untested) plugin that modifies the query args to not only reduce it to a single query, but mo...
Single page theme that uses pages for the content
wordpress
WPML plugin comes with its own CSS file. I want to get rid of all the CSS it contains, so I put everything between <code> /* */ </code> . However I'll have to do that again when I'll update the plugin. Is there a way to "unload" a CSS file ?
You can use wp_dequeue_style function, with a wp_enqueue_script hook with priority higher than WPML's wp_enqueue_script hook. Put the following code into your functions.php: <code> function dequeue_wpml_styles(){ wp_dequeue_style( 'wmpl_style_handle' ); } add_action( 'wp_enqueue_scripts', 'dequeue_wpml_styles', 20 ); <...
Deregister a CSS file that comes with a plugin
wordpress
When a user upload images, by default, the Attachment Post URL option is selected. How can I change the default to be "File URL"? If that is not possible, how can I remove the attachment post url completely? I made a Google search that brought more questionmarks than answers. EDIT: I found a way to disable the attachme...
Youre almost there. The func I show in stackexchange-url ("this thread") sets the 'large' as default, but also, in that thread, you'll see There is a hidden options page in WordPress under yoursite.com/wp-admin/options.php On that endless list of undocumented options you can set a value for "image_default_link_type". Y...
Change default from "Attachment post URL" to "File URL" in Add Media
wordpress
I have the following code in my template page and I have registered jquery and fittext in my theme's <code> functions.php </code> . They are currently showing up in the footer as I set them to. I can set them up in either the header or the footer, but fittext just is not working where ever I place it. When I reduce the...
I figured it out finally, for some reason using the $ in my script just doesnt work so I had to use jQuery instead like this <code> &lt;script type="text/javascript"&gt; jQuery(document).ready(function() { jQuery("#fittext3").fitText(1.8, { minFontSize: '12px', maxFontSize: '75px' }); }); &lt;/script&gt; </code>
Trying to get fittext to work in Wordpress
wordpress
The feature did work in the past however pages now seem to default to 'Default Template'. I can see my available page templates in the drop-down on the Page edit page, however after saving the admin simply shows 'Default Template' again. I have tried disabling all plugins as well as remaking some of the templates, howe...
Turns out this was an issue with my hosting. phpmyadmin although reporting operations as complete was not actually committing repairs / optimisations. Now querying why this is with the company. So the simple fix was indeed to simply repair + optimise the table.
Wordpress page edit does not save selected template
wordpress
I am using BuddyPress 1.6.1, bbPress 2.1.2 and WordPress 3.4.2 I follow the guide here . In the end, I did the trick pointed out by Sarah Gooding because mywebsite.com/forums was blank right after the above installation Created a page called "Forums" with permalink mywebsite.com/forums Insert bbPress shortcode [bbp-for...
I have found the answer for myself actually. Yes, I love the fact that bbPress is not obtrusive! It almost doesn’t matter at all how I am trying integrate BuddyPress here. So this narrow downs to customise bbPress template when installed as a plugin to WordPress. The answer is here: http://codex.bbpress.org/legacy/step...
How to edit bbPress template files - WordPress + BuddyPress + bbPress?
wordpress
I've built a super-crazy Wordpress framework that has a million and one shortcodes, one of those is a columns shortcode which supports a count parameter that allows you to define a column and the appropriate class will be added. My shortcode is as follows: <code> add_shortcode('column', 'column_shortcode'); function co...
This is a known issue. If you have one shortcode inside another which has the same name, the wordpress parser will not be able to handle them correctly. This is also mentioned in the codex page for shortcode API under limitations. From the linked page <code> However the parser will fail if a shortcode macro is used to ...
Does Wordpress support a shortcode calling itself from within a shortcode call?
wordpress
I recently removed the restriction on the following page: http://www.boulderwritersworkshop.org/2012/10/21/david-jessup/ I can now view it without being logged in. However, if I post this URL to my Facebook wall, it shows the "Join" page, as if Facebook thinks I need to log in the view that content. I tried clearing Qu...
remove the trailing slash and it works fine. http://www.boulderwritersworkshop.org/2012/10/21/david-jessup
Unprotected page appears protected when posted to Facebook (S2Member)
wordpress
I'm looking for a way of selecting the users for one site within a multisite set up. Can anyone tell me how to do this please? This is what I have at the moment: <code> $user_search = $wpdb-&gt;get_results("SELECT ID, display_name, user_email FROM ".$wpdb-&gt;base_prefix."users"); </code> but this selects all users acr...
get_users function is the method you should use to query users, and by default it retrieves only users of the current blog in a multisite setup.
How do I list multisite users for the current site only
wordpress
It's always been a pain in the @$$ to see only 20 item in category. If i have 30, it paged on 2 pages, i hate that. If WordPress had a preference for that. So the question, Hot to list ALL the category, whatever the number... if i have 200, list them all, no paging. I inspect edit-tags.php and could not find "show_item...
It is absolutely not user friendly, but i have found it - after coding and reading 10-15 pages of plugin code that does exactly that. It is options in <code> Screen Options </code> slide-down menu (at the top of every screen). Keep that for future reference!
How to change how many list item show in category generated by file edit-tags.php
wordpress
My Title tags same sentence show twice. please see it . how i can solve this problem . my site
Go to the header.php file in your template folder and make sure that between the title tags, there's only this code: <code> &lt;?php wp_title('');?&gt; </code> That should do the trick. This error is a combination of your template files with standard settings of the Yoast SEO plugin.
Title tags show twice
wordpress
I'm currently adding thumbnails to my page with: <code> &lt;?php the_post_thumbnail( 'category-thumb' ); ?&gt; </code> and this in the fuctions.php: <code> if ( function_exists( 'add_image_size' ) ) { add_image_size( 'category-thumb', 200, 142 ); } </code> How do i stop the title tag from being added?
This filter will remove it completely from all images, you can add a conditional to only effect certain images. <code> function remove_img_title($atts) { unset($atts['title']); return $atts; } add_filter('wp_get_attachment_image_attributes','remove_img_title'); </code> Instead if you want to use <code> &lt;?php the_pos...
Removing Title Tag from Thumbnails
wordpress
I'm working with the ProjectManager Plugin (by Kolja Schleich) and i've exausted myself trying to find the code that controles the Internal Link Form field. Does anyone out there in the magical world of the internet know where this code is located? UPDATE: http://wordpress.org/extend/plugins/projectmanager/ is the plug...
Not 100% certain but you could check admin/dataset-form.php around line 92 <code> &lt;?php elseif ( 'project' == $form_field-&gt;type ) : echo $projectmanager-&gt;getDatasetCheckboxList($options['form_field_options'][$form_field-&gt;id], 'form_field['.$form_field-&gt;id.'][]', $meta_data[$form_field-&gt;id]); ?&gt; </c...
Projectmanager Internal Link Code Location
wordpress
I am using the following code to print out the last 8 published post in columns of 3 so 3 column and 3 rows : <code> &lt;?php $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 8, 'paged' =&gt; ( get_query_var('paged') ? get_query_var('paged') : 1) ); query_posts($args); $x = 0; while (have_posts()) : the_...
Multiple nested <code> if </code> statements can create a mess you might look into using a <code> switch </code> for this case. Something like: <code> //your $args $the_switch_query = new WP_Query($args); while ( $the_switch_query -&gt;have_posts() ) : $the_switch_query -&gt;the_post(); $query_number = $the_switch_quer...
How to place an image after Nth number of posts in query_posts
wordpress
If post content exists, do not display featured image, if it does not exists, then display featured image or url. So, basically I want featured image to be displayed only if nothing else in post content to be displayed. Thanks!!!!
Just check the raw post content without any filters: <code> if ( "" === $post-&gt;post_content ) { the_post_thumbnail(); } else { the_content(); } </code>
If post content exists (any post content), do not display featured image
wordpress
I don't know whats causing the problem but the <code> echo do_shortcode </code> is not working on my theme's template, but its working on my plugin's template and the shortcode is working on my posts and pages. Pretty weird. Here's the code <code> &lt;?php $my_query = new WP_Query('category_name=video post&amp;posts_pe...
According to the developer of the jwPlayer it was necessary to implement the plugin as a filter to be able to support '.' in tag attributes. Hence <code> do_shortcode(..) </code> does not work but <code> jwplayer_tag_callback(..) </code> will return the desired result. Matching your example simply execute: <code> echo ...
echo do_shortcode is not working on theme's template
wordpress
When you login to the admin you see the Welcome page by default. A client of mine requested to see the "Pages" page by default, he had seen it somewhere else. Is this possible, and if so, how? Tried searching but found nothing relevant, didn't find it in the settings either.
This should work for you if you put it in your themes functions.php file, but you may want to modify the conditions, and the url to redirect to depending on your set up. <code> function loginRedirect( $redirect_to, $request, $user ){ if( is_array( $user-&gt;roles ) ) { // check if user has a role return "/wp-admin/edit...
Change admin startpage to Pages-page?
wordpress
How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop? The function below is from the twentyeleven functions.php file. I'm using the standard comments.php file from twentyeleven, and the trackbacks are shown under the comments when using <code> &lt;?php comments_template( '', true...
Use the <code> type </code> param in the function <code> wp_list_comments() </code> . Copy the comments.php to your Child Theme. search for <code> wp_list_comments </code> . Find this: <code> &lt;ol class="commentlist"&gt; &lt;?php /* Loop through and list the comments. Tell wp_list_comments() * to use twentyeleven_com...
Display trackbacks separately from comments in twentyeleven
wordpress
I'm using the Posts 2 Posts plugin specifically, but I think this applies to any meta box. I have three Posts 2 Posts metaboxes on the side: "Related Case Studies", "Related White Papers" and "Related Videos". I'd like the client to be able to drag these, and have the metabox order correspond to the order they appear o...
It's not that hard: There's a user Meta entry for that. You can not only retrieve the order, but also which ones are hidden (just to get one step further). <code> # Meta Box Order $meta_box_order = get_user_meta( wp_get_current_user()-&gt;ID ,sprintf( 'meta-box-order_%s', get_post_type() ) ,true ); # Hidden Meta Box $m...
Get Order of Meta Box in a Page/Post
wordpress
Tried to make a simple redirect for some users I don't want to access the wp-admin/, so I did this code: <code> function no_admin_access() { if ( !current_user_can( 'delete_posts' ) ) { wp_redirect( site_url( '/' ) ); exit; } } add_action('admin_init', 'no_admin_access'); </code> But when I then try to make a ajax requ...
You can and a check for the <code> DOING_AJAX </code> constant which is defined on an Ajax in your conditional check: <code> function no_admin_access() { if ( // Don't do this for AJAX calls ! defined( 'DOING_AJAX' ) // Capability check &amp;&amp; ! current_user_can( 'delete_posts' ) ) { // Redirect to home/front page ...
Redirect users away from Admin breaks ajax
wordpress
I would like to build a site for a religious group that follows a Church calendar year that highlights seasons by different colors. Is there a way with existing WP / php / css / framework to schedule a different color profile for a theme based on the date? casey
You could just create different style sheets for each color profile, and load those depending on which month it is. Here's a basic example showing how you could load a halloween.css file for october, and an xmas.css file for december. The code below would go in your themes functions.php file: <code> add_action('wp_enqu...
Does WP, php, or a current framework (woofoo / genesis, etc). Offer a way to schedule text / bg color changes?
wordpress
I created a Custom Post type and in that custom post type have a hierarchical taxonomy (categories). Here's an example of the categories I made: <code> Hats - Mens - Womens Shoes - Mens - Womens </code> The problem is that when I go to the "Mens" sub-category of the "Shoes" Main category it goes to the Mens category of...
This is a problem with wordpress that happened to me as well. If the titles of 2 terms (even if they are from different taxonomy), wordpress will not create another term in the database, instead link the previous term to taxonomy. If you look in your database, you'll find only 1 term with title "Mens" which will be a c...
Custom Taxonomy Taxonomies of Same Name point to first created URL
wordpress
Apparently this is very popular issue. There are already bunch of people offering answers for this. But somehow after hours of searching I still can't get the solution. I hope someone can give me a clue here. Currently I created a page for displaying all post from my custom post types. Here is my page template codes: <...
Try the following and see how you go.. <code> &lt;?php global $paged; global $wp_query; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query-&gt;query('posts_per_page=10&amp;post_type=your_post_type'.'&amp;paged='.$paged); while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post(); ?&gt; &lt;!-...
Pagination doesn't work in custom page template
wordpress
I'm developing a Wordpress theme with a few other individuals and am running into a problem where I add a plugin and then I have tell the other developers about the plugin I installed and the settings I set for the plugin so that the theme works. I was wondering if there's a way to associate plugins with a theme, so th...
There isn't any such feature directly in wordpress but there is a php library that do allow this kind of behaviour. Can't comment on how/if it works as I haven't tried it yet but it looks like it does the job. You might find it useful http://tgmpluginactivation.com/
Is there any sort of theme dependency management?
wordpress
Say I have the ID of a product in wooCommerce; can I generate its URL somehow? (example /shop/fresh-apples)
Products in WooCommerce are a custom post type, so this should work: <code> $url = get_permalink( $product_id ); </code> You can treat that <code> $product_id </code> as a postID (that's what it is), so you can use it with other normal WP functions, like: <code> echo '&lt;a href="'.get_permalink($product_id).'"&gt;'.ge...
Given the ID of a product in woocommerce, how can I get its URL?
wordpress
My client needs to work out the shipping only after someone has made a "purchase" on his site so by default, this option needs to be switched off and yet, when I switch shipping off, I still get shipping options coming up everywhere. I could hide this with CSS but if the option to switch off shipping is there, I would ...
Tried here? settings-> store-> presentation :Display per item shipping
Switching off shipping in WP-eCommerce
wordpress
i want to create, how many visitor open this post it display in homepage below of summary like this .how i can do it? my site .my css code /***** Structure and Layout *****/ body { font: 62.5% Arial, "Helvetica Neue", Helvetica, sans-serif; color: #666; } #angles { position: relative; width: 100%; } .inner-wrapper { po...
The simplest solution would be by using a plugin. For instance: http://wordpress.org/extend/plugins/baw-post-views-count/ . Your CSS has nothing to do with it
how many visitor open this post?
wordpress
Is there a good way to know if a post has an image attachment of a particular size? I'm trying to fetch 5 random posts, but I only want results that have image attachments with a (custom) size of "extra_large". I'm trying: <code> $images = get_posts( array( 'post_type' =&gt; 'attachment', 'orderby' =&gt; 'rand', 'posts...
The image attachment type is stored in the postmeta table in the <code> _wp_attachment_metadata </code> meta key. The data is serialized, so it can't be filtered on. But you could use a meta_query in your query: <code> $images = get_posts( array( 'post_type' =&gt; 'attachment', 'orderby' =&gt; 'rand', 'posts_per_page' ...
get post attachments of a particular size
wordpress
When trying to login one of my WP installs (regular WP 3.4.2-no multisite), I keep being redirected to the <code> wp-login.php </code> file. I've checked nearly everything: Password is correct and changed...nothing Reset to a default theme...nothing Deactivated al plugins...nothing Reuploaded my wp-login.php file...not...
I've solved the problem by putting back a backup of the evening before the problem.The cause of this problem will never be known. Server logs (access and error logs) don't give a clue. WP_debug doesn't give a clue. Every FTP file has been checked and overwritten. The problem must be in the database somehow, but the wp_...
Can't access wp-admin
wordpress