question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work? <code> &lt;?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query-&gt;query('post_type=videos&amp;showposts=1'.'&amp;paged='.$paged); while ($wp_...
Found the answer: After a looong day debugging thru wordpress core, I managed to solve this issue. Basicly, you CANT have a PAGE and a CUSTOM POST TYPE with the same name. If you do, the permalink rewrite rules will get confused and trigger a 404. A very simple solution I'm using is: The page that lists the custom post...
Why is "/page/2/" not working?
wordpress
The body_class hook seem only to work with non-admin pages. When I do <code> add_filter('body_class', 'add_body_classes'); function add_body_classes($classes) { $classes[] = 'myclass'; return $classes; } </code> Is there another hook i should be using if i want to add a class to the body of an admin page?
Admin doesn't use <code> body_class() </code> template tag, use <code> admin_body_class </code> filter too add classes to admin body tag.
body_class hook for admin pages
wordpress
I use front end posting on my site so I don't get a chance to set a featured image for alot of my posts. So I use catch_the_image to get thumbs but it gets the original size and then scales it which is hurting page speed. Basically what I want to do is add "-150x150" into the string in the function so it pulls the smal...
You can add your own named image size by adding code to your functions.php. Something in the line of add_theme_support('post-thumbnails');//might not be necessary add_image_size('front-end-150', 300, 300); Now you should be able to use in your catch_that_image() <code> wp_get_attachment_image($post-&gt;ID, 'front-end-1...
Using catch_the_image to get the thumbnail size
wordpress
The code below is based on a couple of forum posts from a couple of places. To a certain extent, it works. The issue I am having is that it only shows "Activities", no matter what parent category I'm in. I tried replacing "activities" with a number of very unsuccessful alternatives (conditionals, get functions, and oth...
If you are in a category context this should work and and you'll get the correct catID to work with. <code> function getCurrentCatID(){ global $wp_query; if(is_category()){ $cat_ID = get_query_var('cat'); } return $cat_ID; } $catID = getCurrentCatID(); </code>
Getting categories to change appropriately when using $cat = ' ';
wordpress
Is there an e-commerce solution for wordpress which will allow a shop with an onsite blog? If so, what are the options and is there generally one thats considered the 'best'?
I highly recommend WooCommerce. Those guys are brilliant. It's based off of Jigoshop another great solution. To me, though, WC is one of, if not, the best solutions for WP e-commerce. Great support. Great themes. Uber easy to integrate with a custom theme as well.
E-commerce for wordpress
wordpress
For a while now I have been building WordPress based sites for clients. These sites tend to be brochure sites so feature a collection of pages all with slightly different layouts within an overarching main layout and style. Upto this point I have either created Pages in the WordPress admin panel and then created a page...
Disclaimer: I have no affiliation with this plugin nor its author, it's just a plugin I've found to be indispensable in my Wordpress tool kit. So this is not an advertisement for a plugin. The plugin you want is: Advanced Custom Fields . It's a free plugin that'll make your life a lot easier for varied post editing pag...
Customizing page content layout
wordpress
I want to display single random post in it's entirety in the homepage.I've tried many methods, but the main issue was that it won't display the content, only heading, or display content, but only an excerpt. Now I have this code: <code> &lt;?php query_posts(array('orderby' =&gt; 'rand', 'showposts' =&gt; 1)); if (have_...
how to show the full post: http://codex.wordpress.org/Customizing_the_Read_More#More_about_.24more I want all the things I get in single.php possibly copy all the code from within the loop of single.php into the loop of your random post. my custom code ... doesn't work in index the <code> in_category() </code> code mig...
Single random post in homepage
wordpress
I am creating a localized instance of WordPress and one can easily configure the category and tag parts of the URL but I cannot find anything similar for authors. So for instance I get this: <code> http://mysite.com/author/borekb </code> instead of <code> http://mysite.com/autor/borekb </code> which would be appropriat...
Use the plugin Edit Author Slug : This plugin allows an Admin to change the author slug (a.k.a. – nicename), without having to actually enter the database. You can also change the Author Base (the ‘/author/’ portion of the author URLs). Two new fields will be added to your Dashboard. The “Edit Author Slug” field can be...
How do I amend the fixed "author" part in the URL?
wordpress
I'm already familiar with the_excerpt() and get_the_excerpt() functions. These two functions relate specifically to some node/taxonomy/whatever (post, page, custom post type) inside of Wordpress, unless I'm mistaken. What if I have some external text, and wanted to pass it through a concatenation function. Does anyone ...
Use <code> wp_trim_words( $text, $num_words, $more_text ) </code> The first argument is the text to trim, the second is the number of words you want and the third is the truncation text which defaults to an ellipsis. The function is located in wp-includes/formatting.php line 1920 (v3.3.1)
What's the internal concatenation function for creating Excerpts with Wordpress?
wordpress
I have create a custom post type with meta boxes. In metaboxes I have create some fealds that the use can use the WordPress ThickBox Media Dialog to upload his/her images for each post seperatly. From the other side, the WordPress, when I upload an image as a Featured image, gives me some functions like the <code> the_...
If you're not opposed to using a plugin to achieve this, I would recommend the Multiple Post Thumbnails plugin. It's very simple to use and provides the same functionality as "the_post_thumbnail()" function.
How to use images uploaded with custom implementation of thickbox like the_post_thumbnail() functionality
wordpress
I'm looking to display a list of posts in the header section on my template on all pages with the exception of the front page where I would like to show an image in place of the list of posts. Is there a function within wordpress to detect the front page that I can use in my template code? or should I just be looking a...
You can use the wordpress template hierarchy to do just that. Specifically, you can put the code you want in <code> front-page.php </code> and then use <code> index.php </code> for the rest of them, though that's a rather bland way of doing design with what you have on your hands. Alternately, there are the wordpress c...
Show a different code on front page to other pages
wordpress
I want to display a random page in the index page of my site and it's all good with that.The problem is that before the post I want to display a page depending in which category the post is posted.Website is about world countries so before the post I want to display a description of the country, some pictures and stuff...
Assuming you have an original query that is wrapping the code you pasted, it looks like <code> &lt;?php wp_reset_query(); ?&gt; </code> is your issue, but I'm pretty sure you should be able to replace it with <code> &lt;?php wp_reset_postdata() ?&gt; </code> to get back to your original $post variable within the main q...
Random post, page inside post loop problem
wordpress
I'm currently collaborating to a wordress.com blog and would like to use the reblog feature to mirror my posts there to my main blog that is a self hosted wordpress installation. My understanding is that this is only possible within wordpress.com so I searched for some plugins to accomplish this and the closest I came ...
Try something like http://wordpress.org/extend/plugins/feedwordpress/ or another RSS aggregator.
Reblog wordpress.com posts on self hosted
wordpress
I like my homepage not to list only one category, but to list all category, group by post. Here is the request : Cat 1 2 3 4 5 and the post will be : post 1 (cat=2) 2(cat=2) 3(cat=1) 4(cat=3) 5(cat=4) 6(cat=4) 7(cat=4) 8(cat=4) 9(cat=5) i like to list cat : 5,2,4,3,1 and when listing them, all the post from cat 5, then...
here is a general structure how I would do it: <code> $categories = array(5,2,4,3,1); //manually enter the array of the category ids in the order how you want them to appear foreach( $categories as $cat ) { $args = array( 'category__in' =&gt; array( $cat ), 'posts_per_page' =&gt; -1 ); $cat_query = new WP_Query( $args ...
How to list post as buch of category, and all of them
wordpress
Is there a function that will return the permalink to a custom post types archives that is available to use in WordPress? Something like: <code> get_cpt_permalink("events") </code> which will return <code> http://example.com/events/ </code> when <code> has_archive =&gt; true </code> on it. If not what would I need to h...
This is what you are looking for <code> get_post_type_archive_link( $post_type ); </code>
Function to get permalink of custom post type archives?
wordpress
So, I want to create different menus for people who are logged in or not. I got a reply that i should use a function <code> if (is_user_logged_in()) { wp_name_menu(array('theme_location' =&gt; 'logged_user' )); } else { wp_nav_menu(array('theme_location' =&gt; 'new_user' )); } </code> So, if I get this right, I put thi...
i just did this for a site i am working on. first i registered 2 menus in functions.php: <code> add_action('init','kia_menus'); function kia_menus(){ register_nav_menus( array('primary-menu' =&gt; __( 'Primary Menu for Logged In Users', 'kia_theme' ), 'primary-loggedout' =&gt; __( 'Primary Menu for Logged Out Visitors'...
How to Use the Function is_user_logged_in To Display Different Menus?
wordpress
I have page with news. I'm displaying them as a shortened text (300 chars limit), I'm removing any images using preg_replace() and everything looks fine, until someone uses line breaks in his post. Things gets messy then and my height is way to high sometimes. Ofc I'm using <code> overflow: hidden; </code> but its not ...
If you run a <code> wp_kses() </code> on <code> the_excerpt() </code> (through a filter) you can whitelist specific HTML tags and such. In your case, the code would probably look something like this: <code> if( is_page( 'your_page' ) ) { add_filter( 'the_excerpt', 'wpse44363_filter_the_excerpt' ); } function wpse44363_...
Fixed height of the_content()
wordpress
I am developing a website on my localhost and i just notice a bunch of incoming links in the dashboard's incoming links section, which doesn't look valid. When i visit the urls i don't see a reffer to my localhost/domain.com. the only plugin i had active was "Regenerate Thumbnails". I disabled the plugin but i can stil...
The incoming links widget is asking Google for links to the domain you’re on right now. If your domain is <code> localhost </code> you get a lot of links – because that’s a very common domain name. Unfortunately, some people don’t clean up their data when they move from localhost to the world wide web, and then Google ...
Local wordpress setup with SPAM in the incoming links dashboard section?
wordpress
I can get the image to appear fine in this bit of gallery code. However the flex slider gets its caption from a <code> &lt;p&gt; </code> tag ( <code> class="flex-caption" </code> ) and I just need to <code> echo </code> out the image title inside that paragraph. <code> &lt;?php if (!empty($flex_gallery)) {?&gt; &lt;div...
You should be able to get the image title with <code> wp_get_attachment_metadata() </code> . It will return an array that contains useful stuff like the width and height, as well as the title.
How do I get just the title from wp_get_attachment_image
wordpress
I'm writing a plugin that sends notifications on various post events. One of the notifications should be sent when a post is assigned to a different author. How can I know that the post author was changed ?
Best Hook for that would be <code> wp_insert_post_data </code> <code> function wpse44358_filter_handler( $data , $postarr ){ //do your stuff //if ($data['post_author'] == ... return data; // make sure you return something } add_filter( 'wp_insert_post_data' , 'wpse44358_filter_handler' , '99', 2 ); </code>
How do I know if author field was changed on post save?
wordpress
I'm using advanced custom fields and I have the following code: <code> &lt;?php $args = array( 'numberposts' =&gt; 3 ); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); ?&gt; </code> Where the number of posts = 3, I was wondering if I could turn this into a custom field in the edit...
It might actually still work, but the syntax is currently wrong (you have a PHP opening tag inside another opening tag). And you can assign the value of the custom field to a variable using the <code> get_field </code> function. What if you try this? <code> &lt;?php // assuming your ACF name is 'number_of_posts' $numpo...
How to make number of blog posts a custom field?
wordpress
I'm doing gallery in a single post after the post thumbnail. So I list all the post attachment with the image type (with the following query) but I want to exclude the post thumbnail. <code> global $post; $args = array( 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -1, 'orderby' =&...
You can use the <code> exclude </code> parameter. <code> global $post; $args = array( 'exclude' =&gt; get_post_thumbnail_id( $post-&gt;ID ) 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'numberposts' =&gt; -1, 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC', 'post_parent' =&gt; $post-&gt;ID ); $imag...
Post Gallery list attachments except the one used as post thumbnail
wordpress
When I change a slug from <code> post-a </code> to <code> post-b </code> , will WordPress create a redirect from <code> /post-a </code> to <code> /post-b </code> , like HTTP 301 or something similar? If not, is there a plugin for that?
I just went and tested this (WP 3.3.1), the wordpress core will automatically do a redirect if you change the post slug, even if you change the slug from <code> post-a </code> to <code> post-b </code> and then to <code> post-c </code> , <code> post-a </code> will return a 301 to <code> post-c </code> . That said, the r...
When I change slug, will WordPress create redirect from the old URL?
wordpress
I am writing a plugin that opens up a form to invite people to a website by email and want to use <code> wp_mail() </code> . Whenever I use the <code> wp_mail() </code> function in any file in my plugin folder I always end up with: PHP Fatal error: Call to undefined function wp_mail() The code segment in question is: <...
You may call the function too early. You have to wait until the action <code> 'plugins_loaded' </code> fires. <code> wp_mail() </code> is defined in <code> wp-includes/pluggable.php </code> . <code> pluggable.php </code> is loaded in <code> wp-settings.php </code> after the plugins are loaded but before <code> 'plugins...
wp_mail is undefined
wordpress
A while ago I created an interactive map for my website using Ian Lunn's BBC News Map , and custom fields to set the html for each area. It looks like this:- I'm now trying to integrate this with a custom post type, the idea is that each map area would become a category with a list of posts in that category underneath ...
The easiest way would be to use a function which accepts a region taxonomy term as an argument, and outputs a list of posts with that term (i.e. 'in that region'). So your template looks like: <code> &lt;!--nw--&gt; &lt;div id="nw" class="counties-container"&gt; &lt;h2&gt;North West&lt;/h2&gt; &lt;p class="nw-t"&gt;&lt...
Integrating an interactive map into a Wordpress custom post type
wordpress
http://www.mywebsite.com/my-page on my wordpress page i have a form and i am redirecting my wordpress page to some other website after form submit i have following code in my functions.php file for submitting form. <code> add_action('init', 'redirect'); function redirect(){ if(isset($_post['submit'])) { wp_redirect("ww...
You need to place http:// in front of the URL for wp_redirect to work properly.
wp redirect 301 not working in wordpress page
wordpress
Done this before and i am still wondering what to do with the wp_posts => guid content, which has reference to http://localhost But at wordpress.org http://codex.wordpress.org/Changing_The_Site_URL it clearly states: Never, ever, change the contents of the GUID column, under any circumstances. But as i understand it is...
"GUID" stands for "Globally Unique Identifier" mainly used by feeds to tell if that specific post was shown on the feed before or not, even if you change domains. When developing on local host and the moving to live (+1 just for that BTW) and no feed reader/burner has read your feeds and only if that is the case it's O...
Moving WP install from local to live, what about wp_posts GUID?
wordpress
I'm using the default Wordpress 2011 theme on a new blog I'm setting up. I've got everything basically setup fine for now. I have experience with PHP/MySQL and HTML/CSS, but haven't used WordPress as yet. When I set the blog up, it asked for a tagline under general settings, which I provided. This is showing below the ...
Ah, figured it out. In <code> /wp-content/themes/twentyeleven/header.php </code> , you can comment out this: <code> // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description &amp;&amp; ( is_home() || is_front_page() ) ) echo " | $site_descr...
How to remove the tagline from the HTML ?
wordpress
As a follow on from my last unresolved query regarding menus, the problem has extended even further. My menus are not printing anywhere in the code. I am registering the menu functions.php: <code> add_action( 'after_setup_theme', 'your_newtheme_setup' ); if ( ! function_exists( 'your_newtheme_setup' ) ) : function your...
it turns out that after copying some code from another post (stackexchange-url for a filter in functions.php to add the search bar in the nav menu, when it wasn't matching the menu, it was returning nothing (i.e erasing the $items) I stupidly copied this code in without testing... and it was the problem all along!
Custom menus not showing
wordpress
I've got an <code> event </code> custom post type, and using filters, I've configured the archive page to show only event in the future, and in chronological order based on a meta value (start date). I want to make a second archive page to show events in the past, complete with pagination, ordered reverse chronological...
This is what I went with. It creates a second archive for past events . It shows upcoming events in the main event archive, and old events in the past events page. Sorting is ascending for the main archive (so you see the next upcoming event first), and descending for the past events page, so you see the most recent ev...
Second Custom Post Type Archive
wordpress
I am trying to select some attachements based on an attachement caption. I need to do this for a seperate download page. On the download page i want to display all attachment which caption equals "downloads". So this way i can be selective of post attachments which can and can't be downloaded At the moment i have this ...
Ok found a solution by using this in the loop <code> if ($attachment-&gt;post_excerpt == 'download') { </code> Where i have put "download" in the caption textfield. hmmm, what if i want to select an image with 2 or more different captions?
How can we select attachements based on Caption?
wordpress
I have added a custom button to the media actions in a custom theme, <code> function wp_myplugin_media_button($context) { $wp_myplugin_media_button_image = '../wp-content/themes/datamine/images/icon_create_table.gif'; $wp_myplugin_media_button = ' %s' . '&lt;a id="fluffyRabbit" href="javascript:;" title="Add a Tabletoo...
I got it to work after playing around for while... this went in the custom js file <code> jQuery(document).ready(function(){ jQuery('#fluffyRabbit').live('click',function() { console.log('o hai!'); }); //console.log('loaded'); }); </code> this went in functions.php <code> function load_scripts() { wp_enqueue_script('jq...
Add jQuery function to media button
wordpress
I am using the default rss feed widget but want to style it. My question is -where to add my piece of code to style the default wordpress rss widget?
You will need to add XSLT sheet to the RSS declaration. It will automatically beautify the RSS XML. You have a tutorial here Otherwise, just use "Advanced RSS" plugin, that allows you to configure the graphics with it ( via XSLT ). Plugin page here
How to style the RSS wordpress?
wordpress
I'm working on a WordPress site we have for some software my lab is developing. What I'd like to do is add a page that would allow collaborating groups to upload their data to us for testing, but that would be hidden from anyone else visiting the site (i.e. the collaborators would have to be logged in to see the page)....
The plugin Omni Secure Files has quite a nice upload interface and different wordpress user roles can be given permission to either upload or just view the uploaded files Update from comment Here's the code I put into a page template to get the basics of OSF working in the front of the site: <code> if (!empty($omni_sec...
How can I create an upload page for (and only visible to) specific users?
wordpress
I've got a custom post type of files I'm trying to list using a new WP_Query. It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field (which I have set to display on the page along with the main content as a secondary "column"), the main content disappear...
You're using <code> get_posts </code> which returns an array of posts, which you can loop through using <code> foreach </code> , but not <code> the_loop </code> . Try this version of the code: <code> function ia_news_display_test($atts){ // [ia_news cat='category' num='numbertodisplay'] extract(shortcode_atts(array( 'c...
Using new WP_Query in shortcode in a custom field causes the main post content to not display
wordpress
If I write and put a line break, it make the paragraph tags appropriately, but on this one page the line breaks aren't there: http://jacksongariety.com/gundoglabs/jobs
The editor is doing fine to add <code> &lt;p&gt; </code> tag on line break. I think what you need is to add some css to add margin to <code> &lt;p&gt; </code> tag so you don't have to add additional or empty paragraph tags (which i see on your current page). try something like this on your css: <code> .entry-content p{...
How can I force the Wordpress visual editor to preserve the line breaks after paragraphs?
wordpress
I recently asked this question stackexchange-url ("Custom post types - Use post_id in permalink structure") and solved it but as I have enabled <code> 'has_archive' =&gt; true </code> the solution given no longer works. Let me explain: I'm after this structure: <code> archive-events.php </code> => /news/events/ <code> ...
To get what you need you have to add a custom rewrite rule and to filter the permalink construction. The following code does both: <code> &lt;?php # -*- coding: utf-8 -*- declare ( encoding = 'UTF-8' ); /** * Plugin Name: Event Permalinks */ // Not a WordPress context? Stop. ! defined( 'ABSPATH' ) and exit; // Wait unt...
Custom post types - Use post_id in permalink structure when using has_archive => true
wordpress
I have on frontend search box, I have implement autocomplete for it, and when I'm logged in, it works great for me. But when I'm not logged in, I get 302 as result of ajax call, response headers have location in it, so it is trying to redirect, I do not know why. I notice a lot of posts around this issue, but none of t...
Sounds like you have an issue with another plugin or function that is trying to prevent non logged in or non admin users access to the wp-admin area so it is redirecting from wp-admin/admin-ajax.php and giving you your 302 response. You need to find the code that is doing this and add a conditional not to redirect if t...
WordPress ajax call for not logged in users, doesn't work
wordpress
I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data and display it all on a table on a single page like so: <code> Channel # | Channel Name | Basic Package | Delux Package...
Welcome to WPSE Jason, <code> get_posts </code> is for querying posts, and the <code> tax_query </code> part of that allows you to select posts which belong to taxonomies of a certain criteria. To get the taxonomy terms of a particular post, use <code> get_the_terms </code> , to which you pass the post's ID and a taxon...
How do I query posts and have their related taxonomies returned in the results?
wordpress
I need to modify the following code to show a placeholder if there is no featured image available. I understand that I need to add a <code> if </code> statement in the following code but wasn't sure of the exact coding I needed. Obviously in plain english it's going to be along the lines of if there is a thumbnail show...
Misspelling of thumbnail (thumnail) in the if statement. Also <code> get_the_post_thumbnail </code> does echo the thumbnail, but just returns the html. You need to echo it. Also, for checking if a post has a thumbnail, you can use <code> has_post_thumbnail </code> . <code> if ( has_post_thumbnail($r-&gt;ID)) { echo get...
Showing a placeholder/default img, if no featured image is set
wordpress
I am making a website about world countries and cities.Every Post will be a city name and will have a category of a country. In the beggining of the post I want to have a brief description of the country instead of writing the same description to 20 or more cities. Is it possible that wordpress would see the category i...
Yup, inside the loop (in single.php for example) you can use <code> get_the_terms </code> to retrieve an array of terms (countries in this case) associated with that post. This will always be an array (or false /error if something has gone wrong) even if there is only one country associated to it. You can then take the...
Is it to possible to insert a page in the post depending on the category ofthe post
wordpress
Does anybody have any idea why on single posts there are no template dropdowns for template selections in WP 3.3.1? I did not find that either in the page administrative area. Thank you
For page templates, click on screen options in the top right corner and check the Page Attributes box. If your theme has no page templates to choose from then the template drop down will not be shown. Posts and other post types do not use or support page templates and never have. Only pages support them out of the box....
WordPress 3.3.1 single post template
wordpress
Okay, so I found this code online that allows you to add the option of how many thumbnails you want to show in the gallery shortcode. The code below is what they say to add to the functions.php file <code> function get_random_gallery_images(){ global $wpdb,$post; $ids = ""; $counter = 0; $number_of_posts = 4; $args = a...
The function you've supplied actually doesn't look that bad. It's almost the same way I'd handle the problem, however if you only ever want to modify the include part and always get the attachment_ids associated with the post, here is what I would do. I would actually create a new shortcode which in turn calls the gall...
Gallery Shortcode Function Help
wordpress
As the title says I'm currently having some difficulties hiding the File URL option via jQuery. I've been trying this: <code> // add_action( 'admin_footer-media.php', 'cor_remove_tr_file_url' ); add_action( 'admin_footer-media-new.php', 'cor_remove_tr_file_url' ); /** * Removes the 'File URL' row */ function cor_remove...
This is because those elements aren't present when the page is finished loading, they're inserted later on using javascript. Try hooking into #media-items and running your code when new elements are inserted rather than when the root element is ready.
Hiding the media-new.php File URL option via jQuery
wordpress
I'm generating this form using Settings API: <code> &lt;form action="options.php" method="post"&gt; &lt;?php settings_fields('XX_theme_settings'); do_settings_sections('my_settings'); ?&gt; &lt;input type="hidden" name="foo" value="bar" /&gt; &lt;input name="SubmitButton" type="submit" class="button-primary" value="&lt...
Using <code> $_POST </code> is too low level. Simply give it the same name as your other options. When you options are displayed they should have the names of the form: <code> my_settings[a_particular_option] </code> . For instance: <code> &lt;input name="my_settings[some_input_option]"/&gt; </code> Then for your hidde...
Settings API - getting hidden input / submit button's name
wordpress
I am using woocommerce, I have setup a variable product. Under each attribute, when I try to add a thumbnail image by clicking on the Insert Into Post button for the Media Uploader dialog, the dialog box becomes empty without any content. In the javascript console in Google Chrome, I get the following error: post.php:1...
I can confirm this was fixed in WC 1.5.2 :)
Woocommerce blank screen variable product attribute image thumbnail
wordpress
I am developing a child theme based on the twentyten theme and now i notice the featured image in the WP backend (wp-admin) shows the wrong scaled image. It shows the "twenty ten" size, meaning an image scaled to x198. How do i show the featured image of my chosen size??? regards,
First: why do you care the size of the thumbnail displayed in the "Featured Image" meta box on the Edit Post screen? Second: that image size isn't defined by Twenty Ten (or any other Theme). It's defined by core, and is actually simply calling the original image size, and scaling it. Edit Whoops; that was wrong. :) Tha...
how to change my child theme featured image dimensions?
wordpress
For example I have in my theme folder named test-pages with some php web pages that display different message, in some part of process I want to pull with file_get_contents to get content of one page from that folder, but I can't do it, it just doesn't work, when I try to access directly to that page, I get 404 message...
Move the template files out of the subdirectory, and put them in the Theme's root directory. Then, if you simply want to include the contents of those template files in other template files, simply call <code> get_template_part( 'test-page-name.php' ); </code> . If you insist on keeping these files in a subdirectory, y...
Custom php page in WordPress theme?
wordpress
I have two custom post types (e.g. post_type_1 and post_type_2) that I would like to redirect to independent templates (single-post_type_1.php and single-post_type_2.php) to handle their display. I don't want to put the display templates in the theme folder as I want them self-contained in their respective plugin folde...
You should be using the template_include filter for this: <code> add_filter('template_include', 'wpse_44239_template_include', 1, 1); function wpse_44239_template_include($template){ global $wp_query; //Do your processing here and define $template as the full path to your alt template. return $template; } </code> <code...
Custom Post Types and template_redirect
wordpress
I've setup a CPT to act the same ways as posts but used to post event details. Thing is that some of the posts are in the future and such have a future date set on them. Problem is that normal users cannot see these posts. So: How do I alter archive-events.php to list future posts too? Showing far future posts first an...
I've been able to solve this myself. My entire code for registering the CPT: <code> &lt;?php add_action( 'init', 'events_post_type_register' ); function events_post_type_register() { $post_type = "events"; $labels = array( 'name' =&gt; _x('Events', 'post type general name', 'project_X'), 'singular_name' =&gt; _x('Event...
How to set a custom post type to have viewable future posts
wordpress
In a multisite setup, you can associate an existing user in the network to a site. The standard wp_insert_user function doesn't seem to have the proper logic to handle. How would I do this for multisite? Also, is there a way to see if a given user is already associated with a particular site?
After looking the code the create user, i found that that I can do: <code> $userdata = get_user_by('login', 'user1'); add_existing_user_to_blog( array( 'user_id' =&gt; $userdata-&gt;ID, 'role' =&gt; 'author')); </code> Fix: was missing closing )
How to associate an existing user to a site in a multisite setup programmatically
wordpress
I'm trying to convert a freshly-installed and functional WordPress into a multisite network. But I'm having problems because of our Apache configuration. We use Apache to randomly redirect requests for domain.com to one of two application servers: app1.domain.com or app2.domain.com. The problem is that WordPress redire...
After banging my head on this for a few days, I found a solution that works. Just add the following to wp-config.php: <code> if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) { $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST']; } </code> This will force WordPress to use the requested domain, instead of the prox...
How to configure Multisite Network with randomized hostnames?
wordpress
This is a bit of a weird request, but I'd like to force loggged-in users (one specifically) to fill out the standard not-logged-in name / email address fields before submitting a comment on the site. [EDIT: I'm realizing this is probably even more difficult than I thought. I not only don't want the comment form to show...
I didn't solve this but don't want to waste anyone else's time on it. I decided to create individual user accounts for every visitor instead.
Force logged in users to still fill out name/address for commenting?
wordpress
As the title says I want to keep images on pages and hide them from posts on my site . How can I do this? Thanks
You can do this with a css solution. Pages and posts have different <code> body_class </code> es, so you should be able target them with <code> page </code> and <code> post </code> respectively. Your CSS would look something like this: <code> .post img { display: none } </code>
How do you hide images from posts only
wordpress
What I want to do is to dislay a description of a country if one of the categories is a country name. It do it like that <code> &lt;?php if(in_category('afghanistan')) { $recent = new WP_Query("page_id=25"); while($recent-&gt;have_posts()) : $recent-&gt;the_post();?&gt; &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt; ...
When you give a page a parent, the slug of the page becomes <code> %parent-pagename%/%pagename% </code> , so you should be able to target it with <code> pagename=asia/afghanistan </code> .
How can one get page by pagename if it is a child page?
wordpress
I have built a plugin that uses a custom post type and a single-.php file for a template. My issue is the custom post type template needs to take on the name of the post type and I need to change that. For example if my post type is called Movies then the template I call is single-movies.php. Also the permalink would b...
You can use the <code> rewrite </code> parameter of <code> $args </code> dynamically. Because the post type is registered every time wordpress loads (not just the first time <code> register_post_type() </code> loads), you can set any of the <code> $args </code> dynamically so long as the <code> $post_type </code> slug ...
Dynamically change Custom Post Type Template OR Change Permalink?
wordpress
I have my FIRST wordpress website and I love it, however I'm not sure if it's my browser (Firefox 8.0.1 for Mac) or my computer or the website itself but it's going really slow. MY SITE is in the finalizing stages and I want to make sure it's smooth. This is my first wordpress site so I can see myself adding a lot of t...
Try Pingdom.
How can I test how fast or slow my wordpress website it?
wordpress
I'm getting 500 errors with AJAX on the admin side. However, these errors aren't being logged in the Apache logs so they're rather hard to debug. Is there some way I can find out what they are? Thanks
Sometimes I have a 500 error ( from NGinx ) just because I have a "character" getting outputted before the first header gets written ( or in-between ). Activate WP_DEBUG = true and see what happens. 99% of the case I could spot the error from there. ( and it was nearly all the time the above error ). Post back if that ...
Why is a 500 error generated by admin-ajax.php not going into the Apache error log?
wordpress
I use the ios app to administer my blog . On occasion I also post life pictures up. Question is that when I post an image up from my iPhone the type (image) is shown in the list of post titles. I can't see where this is set? When I go into edit the above post or even create a new post. Is this down to the current theme...
The Wordpress iOS app tends to favour setting a default post format value depending on the content. What you are seeing is called a Post Format, you can read all about them here . It sounds to me like you're using a default Wordpress theme or a theme that uses post formats. The default TwentyEleven Wordpress theme uses...
Post types - Normal Post - Image
wordpress
The theme I am using does most all the SEO stuff that I want it to with the exception of tweaking the titles on a post by post basis, and the ability for me to write my own meta descriptions for each post. I just looked at my source code and I noticed lots of duplicate code. I'm wondering what the best practice is to c...
As far as my usage with Yoast's WordPress SEO plugin goes, I thought always assumed the plugin simply replaced any existing code with what it generates for that same purpose. If you are using the plugin and don't want to disable it, then simply go into your header.php file and delete/comment-out any meta tags that are ...
Yoast SEO Plug In and my Theme duplicating code. Need some feedback on what to do?
wordpress
Having some issues on the tag.php page. Right now it just give me a "nothing to show" If I have no query it shows posts, but I want to change the number of posts per page. Changing the reading settings in the admin is not an option in this case, so I'm looking for template tag ideas only. Any suggestions on ways to re-...
After some other attempts I Found the syntax solution I was looking for. Just sharing. <code> &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string .'&amp;posts_per_page=10&amp;paged=' . $paged); if (have_posts()) : while (have_posts()) : the_post(); ?&gt; </code>
tag.php pagination and query_posts()
wordpress
I want to deliver WordPress powered packages to some users and want them to have: a limitation on disk quota (/each user) A way to measure/show how many MBs they are currently using Any solution would be appreciated
I would use a multi site installation for this. Give each user their own blog. Multi Site has built in disk quota functionality, and you can see how much of it is used and such in the admin area of each site. You can set the quota in the network admin: <code> settings &gt; network settings </code> . Combine that with d...
Measure and limit file uploads
wordpress
I'm using the Wordpress related plugin which is great but I would like to display the feature picture of the page. It mentions on http://wordpress.org/extend/plugins/related/installation/ about using a custom code. Below is what I have so fave but I'm looking to add the feature image thumbnail to the related post. <cod...
Have worked it out and have the following code: <code> &lt;?php $rel = $related-&gt;show(get_the_ID(), true); foreach ($rel as $r) : echo '&lt;a href='.get_permalink($r-&gt;ID).'&gt;'.get_the_post_thumbnail($r-&gt;ID, array(50,50)).'&lt;div class=page-related-title&gt;'.$r-&gt;post_title.'&lt;/div&gt;'.'&lt;/a&gt;'.'&l...
Wordpress Related Plugin - Adding an image
wordpress
Does anyone know what file contains the theme control, specifically the get_header(), in the All-In-One Calendar plugin? Thank you.
AI1EC is driven from <code> page.php </code> in the active "theme" directory.
All-In-One Calendar Plugin: Where is the get_header() control for the template?
wordpress
I have a videosite based on wordpress. I would like it to show a icon on the posts from today. I've tried googling it, but without any succes at all. Any ideas on how to do it or maybe someone has a link to a tutorial on it? Thanks in advance :-)
you can use the difference between the post time ( <code> get_the_time() </code> ) and the current time ( <code> date() </code> ) - for instance, this snippet added to functions.php of your theme would add a new css class to <code> post_class() </code> if the post is less than 24hrs old: <code> function post_from_today...
How to display a "NEW"-icon on posts from today
wordpress
I'm trying to load a CSS file for my WordPress post area, but having no luck. I have read over the wp_enqueue_style function and came up with the code below, but it doesn't load up. Is there a tag or character missing from my code. I have a custom write panel when a user post that I want to style with the CSS file. Any...
Just hook your callback into <code> admin_print_styles </code> , i.e.: <code> add_action( 'admin_print_styles', 'mytheme_add_init' ); </code> Alternately, you could add an <code> is_admin() </code> conditional wrapper inside your callback, and hook into <code> wp_enqueue_scripts </code> : <code> function mytheme_add_in...
How do I load a CSS style into WordPress admin area only?
wordpress
I'm about to make a new child theme and really would like to learn a bit about making it responsive. The design/changes will be rather small. I've done some child themes for both Twenty ten and Twenty eleven but not sure which one to choose for trying to learn responsive design. You could argue Twenty eleven is the lat...
Both Twenty Ten and Twenty Eleven are being maintained, since both are still bundled with core. However, Twenty Eleven has newer functionality, and a better overall codebase. I would recommend using Twenty Eleven. The only reason to use Twenty Ten, really, is that the codebase is considerably more simple. Note: when Tw...
Twenty ten or Twenty eleven as base for responsive child theme
wordpress
I have several custom media sizes we always use. vertical: 95x117, 130x160 horizontal: 440x304, 220x152 home: 260x160 Is there anyway to set the thumbnail, medium and large to vertical parameters and horizontal ones? Or is it better to leave the defaults (150x150, 300, 1024) so that I can set the sizes using width and ...
I would not alter the core intermediate image sizes. If you have custom image sizes, register them using <code> add_image_size() </code> . e.g. <code> function mytheme_add_custom_image_sizes() { // Add "vertical" image add_image_size( 'vertical-a', 95, 117, true ); add_image_size( 'vertical-b', 130, 160, true ); // Add...
formatting horizontal and vertical images in Settings?
wordpress
I have this function in Wordpress that counts 10 users by default. I would like to change it from showing 10 users to infinite number. There should be no end to counting. How can I do this? <code> function get_random_followers($userid, $count = 10){ $followers = get_the_author_meta('followers', $userid); /** if no foll...
This looks like a custom function. It's passing <code> $count </code> to a function called <code> array_pick() </code> to limit the size of your follower array. It also looks like <code> array_pick() </code> is a custom function. But you can easily stop the function from limiting your count by removing the call to <cod...
Infinite counting in Wordpress
wordpress
I'm registering my CPT like so: <code> $args = array( 'labels' =&gt; $labels, 'public' =&gt; true, 'hierarchical' =&gt; false, 'rewrite' =&gt; array( 'with_front' =&gt; false, 'slug' =&gt; 'news/events' ), 'supports' =&gt; array( 'title', 'editor', 'thumbnail' ) ); register_post_type('events',$args); </code> Now that w...
@Bainternet - your answer didn't fully work but I did some more searching and was able to piece this filter together that did work: <code> add_filter('post_type_link', 'custom_event_permalink', 1, 3); function custom_event_permalink($post_link, $id = 0, $leavename) { if ( strpos('%event_id%', $post_link) === 'FALSE' ) ...
Custom post types - Use post_id in permalink structure
wordpress
I am in the process of writing my first plugin and my call to the <code> plugin_basename(__FILE__) </code> function results in a: PHP Fatal error: Call to undefined function plugin_basename() My plugin resides in a directory of its own under the standard wp-content/plugins/. I am also using wordpress 3.3.1 and have loo...
I know its been a while but the answer to the problem above is to create a main file for a plugin and require all related files as required inside that main file. This would avoid the problem because the main file will only be called once and the constants will be defined. The problem occurs when the file is accessed a...
PHP Fatal error when using plugin_basename
wordpress
I have a custom post type called "Films" that is used to manage an entire film collection. I would like to create a custom box with a message that will sit on top of all of the posts when you click on the Films button in the wordpress admin area. Currently (and by default) there is no messaging, just an index of all th...
<code> add_action('admin_notices', 'my_custom_notice'); function my_custom_notice() { global $current_screen; if ( 'my_post_type' == $current_screen-&gt;post_type ) { echo "&lt;h1&gt;Whatever needs to be said&lt;/h1&gt;"; } } </code> Put this in your functions.php or plugin file. Replace 'my_post_type' with the name of...
Show Custom Message in Wordpress Admin
wordpress
I am hoping someone in this group can help me. We’re interested in obtaining more information on where people click on the site, ideally in as simple a way as possible. I looked up “heatmaps” on WP, and found some plug-ins, we want to avoid third-party services such as Crazyegg, so “WP Super Heatmap” jumped out (five s...
In the past I have used ClickHeat which has (seemingly third party) plugin for it in repository , but I just integrated it manually.
A good heatmapping plugin for WordPress? (No 3rd-party services please)
wordpress
How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: <code> &lt;?php $today = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y"))); $the_query = new WP_Query( array ('showposts' =&gt; 10, 'post_type' =&gt; 'page',...
Custom meta boxes store values in the same way as custom fields, they just have a prettier UI. You shouldn't need to modify your query in anyway other than knowing the <code> key </code> under which the custom meta box stores it's values. If you're using a plugin to generate the custom meta box, you'll have to dig into...
How to grab metabox value in wp_query meta_query key
wordpress
I want to import users from a Wordpress installation to another. Same domain, but complete different websites. Website A (old, 700 users): running WP3.0 plain installation + BBPress 1 .x Website B (new, no users): WP3.3.1 MULTISITE installation + BBPress 2 .0 + Buddypress 1.5.4 database will change as well, Website B w...
I would setup your Website B, add a user through the control panel, then view what tables in the database they were added to and what extra fields were set. Then use Navicat or phpmyadmin to dump users from Website B into excel, combine the users from Website A, set any missing fields then import to Website B
Best practice to import user base (subscribers) from one website to another?
wordpress
I'm currently developing a plugin to display some custom data on my wordpress site. For example I have a data named <code> abc </code> . If a visitor try to access <code> localhost/wordpress/abc </code> , it should display the data programatically from code. But if a valid post url is accessed like <code> localhost/wor...
You may take a look at my 404 Tools plugin . I run a filter on <code> '404_template' </code> there. The filter function is getting the template URL as an argument, and it is still possible to send HTTP headers. You could hook into this filter too, prepare some data you may need to print out later, change the template (...
Show custom data instead of 404
wordpress
I finally managed to create working validation callback for Settings API with big help of Chip Bennet, there's only one glitch that I'm not sure how to fix. Here's the foreach loop from my validation function: <code> foreach ($settings as $setting) { $id = $setting['id']; $type = $setting['type']; $option = get_option(...
If you have an options page (which should be inside one form), then all data is sent from that form, regardless of whether or not the option has been changed. The array received for validation is the data received from (your part of) the form. If the data is 'empty' it is because the data wasn't sent. Normally this wou...
Settings API validation callback
wordpress
What I want: http://i.imgur.com/jH6Dj.png (sorry for linking out, I am a new user here so can't post an image inline) How does one list posts by an author within a category, with a count for each category, on the author archive page?
Not the most efficient way but it works, put this in your theme's functions.php <code> function author_post_breakdown($author_id){ //get all post of this author $n = get_posts(array( 'author' =&gt; $author_id, 'posts_per_page' =&gt; -1, 'fields' =&gt; 'ids' ) ); $cats= array(); //loop over all post of this author and g...
How to Insert A List of Posts in A Category Written by the Author into the Author Archive
wordpress
I use PageLines free version, with WordPress 3.3.1, for this website: http://new.teleosis.org/?page_id=76 I want the background color of the whole page to be light green, and the background color of my content area to be white ( screenshot ). I configure the Page Background Color in the PageLines settings, which affect...
Looking at your code, this is a very very VERY bloated theme. Seriously, there's no reason a page that simple should take over 4 seconds to fully load. In addition to the "way too many nested DIV's" issue, areas above and below the header menu span the entire page, so you can't actually change just that section of the ...
PageLines theme: how to change the background color of the main content vs. entire page?
wordpress
I've got url-rewriting partially working. I have this rule: <code> add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?p=27&amp;target=$matches[1]&amp;arrival=$matches[2]&amp;departure=$matches[3]','top'); </code> When I request a page like this: <code> http://yourpage.com/wp/somepage/florida/02-03-2012/0...
Okay I figured it out. Instead of using this rewrite rule: <code> add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?p=27&amp;target=$matches[1]&amp;arrival=$matches[2]&amp;departure=$matches[3]','top'); </code> I now use this one: <code> add_rewrite_rule('^somepage/([^/]*)/([^/]*)/([^/]*)/?','index.php?...
Keep requested/entered url with add_rewrite_rule
wordpress
If you want a custom admin page for a taxonomy, you can set <code> 'show_ui' =&gt; false </code> when you register it to suppress the default admin page and then create a new admin page to replace it. However <code> edit-tags.php?taxonomy=taxonomy-slug </code> still takes you to the 'hidden' default admin page. Is ther...
Not sure why I didn't think of this earlier. I suppose I was hoping for a way to 'hijack' the default page to display something else... Anyway following my original method: If you want a custom admin page for a taxonomy, you can set 'show_ui' => false when you register it to suppress the default admin page and then cre...
Custom taxonomy admin page
wordpress
I have a list of attachment IDs which are built using this array: <code> $all_images = get_posts( array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, ) ); </code> Is it possible to take the image ID from this list and find the Title and permalink of the POST the image is attached to? I know it's feasible bec...
So, if you start with this: <code> $all_images = get_posts( array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, ) ); </code> Then <code> $all_images </code> is an array of objects . Step through each one: <code> foreach ( $all_images as $image ) {} </code> Inside that foreach, you can use the normal paramete...
Find the post an attachment is attached to
wordpress
I have three separate search boxes on my website: <code> species </code> CPT search, <code> glossary </code> CPT search and a general search which I'd like to search <code> post </code> and <code> species </code> post types. My questions are threefold, What's the most efficient/effective code to make pretty search URLs...
Pagination can be done in exactly the same way it works everywhere else in the search archive template. There's no need for your custom query and type variable in search.php either. To search for a particular custom post, you can either modify the query, or you can go to that posts archive and append the search query, ...
WordPress search: pretty URLs (permalinks), custom post types and pagination
wordpress
can I use a category as common for more than one custom post types? In this case same category will have more than one type of posts..
When you use <code> register_taxonomy() </code> , the second argument is the <code> object_type </code> argument, which accepts either a string or an array. You can pass this an array of objects to apply the taxonomy to, and it will be common between those. So, for example: <code> array( 'cpt_slug', 'post' ) </code> wo...
Common categories for two custom post types
wordpress
When I try to import some content to my local site so I can work on the theme w/ relevant data, my import hangs forever.... and if it finishes then the media/images fail. based on some suggestions at stackexchange-url ("Failed media import") i checked my uploads folder... which was for some reason marked read-only. i u...
I had the same problem today and the client just gave me his login credentials... The WordPress Import plugin is a...well.. If you don't have a ftp account to grab the data, you can use a plugin like "WordPress Backup to Dropbox" to get the data ( there are other plugins which export to other services as well ) and a p...
Failed Media Import (importing from LIVE to local)
wordpress
i need to know if has some plugin to control category of each user can post. Exemple: USER A - Only can post on the category A USER B - Only can post on the category B Thanks for TIPS!!!
I actually have a plugin that does just that, it adds a category dropdown to the user profile edit: Only user who can <code> manage_options </code> (admin) can see that field. and once the user is logged in to post he sees this: Update Its now in the plugin repository http://wordpress.org/extend/plugins/author-category...
Control Category of each user can post
wordpress
Hello I have a query that gets a post with id=x and it works but it leaves out the comment box. Is there a way to add "get comment box" to the query? <code> &lt;?php $post_id = 104; $queried_post = get_post($post_id); $content = $queried_post-&gt;post_content; $content = apply_filters('the_content', $content); $content...
First of all, welcome to WPSE! By default, the comment box does not come with the post object, what you are looking for is the <code> comments_template </code> function. It should be as simple as changing your code to this: <code> &lt;?php $post_id = 104; $queried_post = get_post($post_id); $content = $queried_post-&gt...
Query get post,how to add comment box
wordpress
My multi-site setup uses sub-directory. I am creating one plugin + one theme to customize each of the sites. Is there any way to have separate plugins and themes folder per site like so or something similar: <code> root +----wp-content | +----site1 | +----plugins | +----themes | +----site2 | +----plugins | +----themes ...
There's <code> register_theme_directory() </code> to ... well register additional theme directories. For plugins, we don't know how to get around it (so far). If you want, then you stackexchange-url ("can jump into the discussion here") and add your thought, share your try-outs and maybe we all together will come to an...
Having separate plugins and themes folder for multi-site setup
wordpress
I've used some custom rewrites implemented by the Roots framework . Occasionally they get wiped: certainly if I visit Settings > Permalinks, but also at seemingly random times. My htaccess reads so: <code> &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^css/(.*)...
There is a <code> # BEGIN WordPress </code> and <code> # END WordPress </code> after the end you should be able to add your own code. Anything between will get overwritten by WordPress
How to prevent WP overwriting my custom htaccess rewrites?
wordpress
I am trying to update my plugins to be more user-friendly. One of the things i want to achieve is that i want my plugins output (e.g. for description-fields) to use the full functionality of all normal wordpress posts and pages (use TinyMCE and Loop-Output). I've found a great article on using the tinyMCE right here bu...
The Solution to my problem is to simply let my plugins output run through the <code> do_shortcode() </code> -Function of WordPress as pointed out by this article: Using Shortcodes Everywhere I updated my plugin so it uses shortcodes, too, so now my output looks like this: <code> // Add this upon plugin initialization a...
Loop output for custom plugin [solution found]
wordpress
As an administrator when I change or edit a post of an author (for example add a category through quick edit) the author of the post changes. We do not want this to happen. Is there a way to prevent this?
Both, quick edit and the regular post edit screen, offer an author field. Just take care to set the correct author when you edit something. To see this field you have to enable it in the screen option in the upper right corner:
Is there a way to prevent author change when editor/administrator edits a post?
wordpress
I have an Events section as follows: ⤍ Page 1) ∟ Subpages 2) ∟ Sub subpages 1) Own template, w/o sidebars, but <code> query_posts() </code> and <code> get_title/excerpt() </code> from N°2 2) Other subpages are listed in a sidebar left menu - and <code> query_posts() </code> N°3 How can I list N°3 titles/excerpt on N°3 ...
If you're loading additional posts/pages, it's better to use a new <code> WP_Query </code> instance. <code> query_posts </code> is only for modifying the main query. As for the dates, store them in a custom field in the format <code> yyyy-mm-dd </code> . You'll use php's <code> date </code> to get the current date, ref...
Query sub subpages based on specific date?
wordpress
I want to establish a relationship between individual post attachments and Users. So far I've got my users listing just fine, but it isn't saving/updating. <code> add_filter("attachment_fields_to_edit", "my_image_attachment_fields_to_edit", null, 2); function my_image_attachment_fields_to_edit($form_fields, $post) { $f...
Got it: <code> add_filter("attachment_fields_to_edit", "my_image_attachment_fields_to_edit", null, 2); function my_image_attachment_fields_to_edit($form_fields, $post) { $form_fields["OwnersHeading"]["tr"] = " &lt;tr&gt; &lt;td colspan='2' style='font-size:16px;padding-left:15px'&gt;Tag Users:&lt;/td&gt; &lt;/tr&gt;"; ...
Saving attachment custom fields
wordpress
I am working on a project, which requires a page visit count to be shown on the single post. How can I do this in wordpress, I am guessing, that I have to store them in the same wordpress db?
You can use custom fields for this. What I would suggest is setting up a shortcode you can put on any page you want to show the counter. For an extremely basic example with no HTML formatting, you can do this: <code> add_shortcode( 'examplecounter', 'counter_shortcode' ); function counter_shortcode( $atts, $content = n...
How to store page visit counts?
wordpress
I want to use the <code> menu order </code> attribute to control ordering for a custom post type that's going to be used for a specific purpose. It's easy enough to add this to the CPT via <code> supports =&gt; array('page-attributes') </code> but how do I expose the menu order value on the admin listing screen for thi...
OK - in the end turned out to be fairly simple - as I'd had some kind of mental block - <code> menu_order </code> is a variable in the <code> $post </code> object (thanks to @brady for reminding me of that). @scribu's post on creating sortable column values then gives the rest. So, assuming the custom post type is call...
Adding 'menu order' column to custom post type admin screen
wordpress
My situation: I'm selling a few products. I need to get some options at checkout (like Do you want to add installation services?) that will affect the price, and I need to reference a custom database table to do some complex price calculations to get a total order price. I wanted to use getshopped.org's wp e-commerce s...
Some inspiration: An old colleague of mine did a similar solution. He created a product, in your case called "Installation service", put it as a draft and added it with ajax when customer added it in the shopping cart, and then updated the total price. In that way the product was added to the order and the total price.
Change how WP e-Commerce calculates price total at checkout
wordpress
I want to change the look and feel of the post edit page without making changes to any of the wordpress core file, which is basically a theme. For example, for any user with role of 'author', i want to display everything in one column and re-arrange the meta boxes. So is it possible to create a theme for one of the adm...
The admin area can definitely be themed, using either CSS, a plugin, or a combination of both. To get started, read the Codex page on Creating Admin Themes . To expand further - any overriding of core WP functions must be done from a plugin. It's fairly simple, and just like any other function override - either adding ...
Change the look and feel of admin pages
wordpress
I am learning to write WordPress plugin and testing out a simple case: hide the admin bar base on user role. So far I have the following in my plugin file: <code> $hidemenu= new HideMenu(); class HideMenu { function hideMenu() { add_filter( 'show_admin_bar' , array($this, 'hideAdminBar')); } function hideAdminBar() { i...
Have you looked at the WP Custom Admin Bar plugin? At the very least it has some code chunks you can deconstruct to point you in the right direction.
Plugin to hide admin menu (vertical menu bar)
wordpress
I have a sidebar text widget, which displays a nice quote that's related to the blog contents. I change the quote every now and then, And I'm looking for a way to create a set of quotes and display one of them at random. Is there a plugin for that?
The plugin repository contains a few options that you could use. At a glance this one looks promising.
Sidebar widget: Randomly select text from a given set
wordpress
I'm trying to list the custom taxonomy term that is attached to the post in question (which is a custom post type). I want to list it without it being a link, it is in fact a title. I've tried this, but it clearly doesn't work. What am I doing wrong? <code> function woocommerce_output_product_brand() { $terms = get_the...
First of all, what is <code> $post </code> ? If you after the global <code> $post </code> , then you have to declare the global in the function. So on the second line you'll need to put <code> global $post; </code> . Secondly, <code> $term </code> is an object. If you are after the term's name, use <code> $term-&gt;nam...
get_the_terms issue
wordpress