question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I would like to add a button to this toolbar, right of "fullscreen": The button should add this: „“ If text is selected, it should get around the text, like this: „selected text“ How can I add such a button to the ed_toolbar (class: quicktags-toolbar)? | Try adding the following code in your function.php <code> add_action( 'admin_footer-post-new.php', 'wpse_64665_add_quick_tag' ); add_action( 'admin_footer-post.php', 'wpse_64665_add_quick_tag' ); function wpse_64665_add_quick_tag() { ?> <script type="text/javascript"> edButtons[edButtons.length] = new edButton... | How can I add a button to quicktags-toolbar? | wordpress |
The WordPress Codex states the the Post Type Names and Taxonomy Names have a limit to the slug name. Register Post Type -- max. 20 characters, can not contain capital letters or spaces Register Taxonomy -- The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces) and not more th... | The <code> meta_key </code> field for the <code> wp_postmeta </code> table is set as <code> varchar </code> type entries with a length of 255 characters. Seems pretty lengthy. It's <code> meta_value </code> partner parameter is set as <code> longtext </code> type. As for the term length, both name and slug are set as <... | Does WordPress limit the length of slug names for Post Meta or Terms? | wordpress |
I want to show excerpt from the post in the below image attachment, here's my code <code> <?php /** * Image Template * * Displays singular WordPress Media Library items. * * @package Thematic * @subpackage Templates * * @link http://codex.wordpress.org/Using_Image_and_File_Attachments Codex:Using Attachments */ // c... | First refer to this stackexchange-url ("answer") by @MikeSchinkel. You can put the function in functions.php Next, just add <code> echo robins_get_the_excerpt($post->post_parent); </code> below the image attachment. Like this : <code> <div class="caption"> <?php echo robins_get_the_excerpt($post->post_pa... | Show Post Excerpt in Image Attachement | wordpress |
I'm working on a theme that uses a slider to display blog posts. Beneath the slider is a pagination that displays like a timeline, with a date instead of a page number, calling the corresponding blog post. I want to display the comments for each post, but outside the slider. So, I have this code in my header, to get th... | Aha, I think my syntax was wrong. I changed: <code> action: 'do_ajax', data: { 'post_id' : '72' //using a post id that I *know* has comments, for testing! }, </code> to: <code> data: { 'action' : 'do_ajax', 'post_id' : '72' }, </code> and I'm getting the correct response from the <code> console.log </code> which shows:... | Load comments per post on click with AJAX | wordpress |
I am trying to set an <code> add_action </code> function in my currently active WordPress theme <code> functions.php </code> file, for a defined <code> do_action </code> function within an activated WordPress plugin. The <code> add_action </code> function in my currently active WordPress theme <code> functions.php </co... | Shot in the dark here, but... It is entirely possible the plugin with the <code> do_action </code> definition is hooked before the theme is processed. Find out where the <code> do_action </code> is defined, and find out when it is being hooked. You might need to hook to the function that the <code> do_action </code> de... | add_action in functions.php, do_action in plugin? | wordpress |
I'm using Last Viewed Posts (LVP) plugin on a qTranslate-enabled website. LVP shows post titles in both languages. I found this hint: stackexchange-url ("titles in recent posts appear together in all languages with qtranslate") But not sure how to apply this filter. Relevant code in LVP: <code> foreach ($zg_post_IDs as... | Solution - take out: <code> foreach($zg_get_title as $zg_title_out) { echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title . "\">". $zg_title_out->post_title . "</a>, \n"; // Output link and title </code> insert: <code> foreach($zg_get_title as $post) { echo "<a hre... | Applying post title filter: Last Viewed Posts + qTranslate | wordpress |
Is there a way of adding settings fields dynamically? I have my own Settings API options generator just like in Chip Bennet's Oenology Theme , everything works perfect but I can't find a way to create dynamic fields. Here's how I add option fields. 1. First I describe all fields: <code> function my_options() { $options... | I built a similar system for my Easy Digital Downloads plugin and I think it behaves the way you want it. I recorded a video tutorial of how the system works. Maybe watch it to get an idea or two? | Settings API - adding setting fields dynamically? | wordpress |
I´m working on a front end registration form adn have gotten as far as getting the standard registration form to work, but... I´d like to add the oportunity to let the user choose his/her own password. I´m a bit noob at this so could anyone plese help me? :) Here is my code so far: <code> <?php if(!is_user_logged_in... | Its Not has hard as you think it is :) Add the password fields to your form : <code> password: <input type="password" name="pass1" style="width:250px; margin-bottom:3px;"><br /> repeat password: <input type="password" name="pass2" style="width:250px; margin-bottom:3px;"><br /> </code> then in yo... | How to let user set password on registration | wordpress |
I am trying to display code in my WordPress page and it isn't working. Everything I read says that you should be able to just use <code> pre </code> tag with code tag and it would be good but when I try to display a shortcode, it renders the shortcode rather than displaying the code. The codex says that using <code> pr... | To display a shortcode instead of rendering it you have two options: Write <code> [[shortcode]] </code> . WordPress will show this as <code> [shortcode] </code> . Escape the <code> [ </code> , write it as as <code> &#x5b; </code> or <code> &#91; </code> . | Show shortcode without executing it | wordpress |
I've been trying to use the "featured image" from the home (the blog index) with no luck. It's working for every single page, but it's not working for the home. The code looks something like this: <code> // Don't use on single posts if (!is_single()) { if (is_home()) { if (function_exists('wp_get_attachment_thumb_url')... | if you are referring to the 'page for posts', then try (only relevant section of your code shown): <code> if (is_home() && get_option('page_for_posts') ) { $img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full'); $featured_image = $img[0]; } else { </code> | Get featured image on Blog Index | wordpress |
I am using Wordpress 3.4.2, latest version! I have no plugins installed except the one that I am writing. So Here's the deal, I'm reading a json feed and i'm trying to import its content into a table that i created in my wordpress database. I've used a similar set of code in another plugin that I wrote and it works fin... | Success! I got the wpdb-> prepare to work FINALLY and I'd love to share my code snippet here -- Hopefully someone else will find this useful. My Situation I was trying to import data from a feed into a custom table from a plugin I am writing. Several websites and even the guys that replied to this thread encouraged me ... | Why am i getting this error? WordPress database error: [Query was empty] | wordpress |
I am developing a theme and I wanted to add some extra content to the built in background options page. I know how to use the settings API to create new theme options and settings but I can't seem to figure out where it's actually calling to the background page. I have searched through <code> wp-includes/theme.php </co... | The page content for custom backgrounds is created in <code> wp-admin/custom-background.php </code> . There is no action available where the fields are printed. To add new fields we have to print JavaScript into the page footer. The action is <code> 'admin_footer-appearance_page_custom-background' </code> . To save tho... | How do I add settings to the Background Options Page? | wordpress |
So, I'm using my wordpress with a static front page and then I have Blog link that opens the blog posts. My question is, how can I apply a different template/styling only to that area? | Refer to the Template Hierarchy in Codex. If you have assigned a static front page, the template that will take priority for that page is <code> front-page.php </code> , and the template for the posts (blog) page is <code> home.php </code> . | Defining different theme for Blog posts page | wordpress |
I have a custom-post-type <code> wr_event </code> whose posts are sorted by <code> meta_key </code> "event_date". Therefore I have this handy function … <code> function get_event_list( $latest = true, $order = 'ASC' ) { echo '<ul class="event-items">'; $yesterday = time() - 24*60*60; $compare = $latest ? '>' :... | create a variable to hold the <code> $current_year </code> you're outputting, and check it against each event's year, resetting the value when you encounter an event with a different year: <code> $current_year = ''; while ( $loop->have_posts() ) : $loop->the_post(); // this is just a simple example of the logic, ... | Custom-post-type-archive: posts sorted/filtered by year? | wordpress |
Working on a website and need loop that will show posts ONLY if custom field value is equal to the current category name. I have category 'fun' and custom field 'genre'. I would like to show on custom archive page only posts that are selected to be under category 'fun' AND at the same time if the value in custom field ... | Something like this should be the query you want to run, it adds a condition to the page query that requires the value in "meta_field" to equal the current category's title. <code> global $wp_query; $args = array('meta_query' => array( array( 'key' => 'meta_field', 'value' => single_cat_title("", false), 'comp... | Loop to display random posts only if a custom field matches category | wordpress |
have a little problem. I'm currently creating a theme, where the article page is not on the home page. The trouble now is that on the home page below are three content boxes and they should not appear on the article page. I created a blog page template (blog.php) and created a new page and inserted the blog page templa... | Take a look at the Template Hierarchy . You most likely want to use <code> home.php </code> as the name of your custom post page. | Article Template | wordpress |
I've got a custom role for my site and users can only access their profile page, this appears to be the minimum for wordpress. However, the accounts are managed by us and this is a private site, we do not want users to be able to change their username, email or password using wordpress. The only issue we have right now... | There are two possible solutions for your problem. You can download "Login redirect" plugin from here: http://wordpress.org/extend/plugins/peters-login-redirect/ You should use a login_redirect filter: <code> function my_login_redirect($redirect_to, $request) { $redirect_url = get_bloginfo( 'url' ) . '/blog/'; return $... | Prevent users from going to wordpress profile after login | wordpress |
I am using a form (gravity form) on my site. The form is inserted in a page (called form_page) on the users dashboard when they are logged in <code> http://example.com/dashboard/form_page </code> I am using a plugin (see below) to dynamically populate the form with content from the post the user is author to. However I... | First of all. The question is a little misleading. What you actually want is "post id(s) for current user". Here we go: <code> // Global variable for current user ID // More information: http://codex.wordpress.org/Function_Reference/get_currentuserinfo $user_ID; // You need to create a new WP query object // More info:... | How do I pass a post ID to the page URL? | wordpress |
My wordpress site supports http and https. What I want to do is to add a widget when surfing over http that says something like "Surf this site secure" to show the visitor that I also have a secured version. I don't want to force them to surf over SSL because I'm using a type of certificate that's not supported on Wind... | WordPress has built-in function for this purpose - is_ssl(). http://codex.wordpress.org/Function_Reference/is_ssl So, you should edit this widget and put something like <code> if ( is_ssl() ) { } else { echo 'you should use ssl'; } </code> | Show widget when not using SSL | wordpress |
I'm trying to migrate my wordpress site from an old host to a new host. The Wordpress Codex says "you can move by just copying your files and database." Copying the files is easy enough, but how do I copy my database? I'm sure I'm just not looking in the right places, but I can't find any documentation on this anywhere... | The same WordPress Codex has a page for backing up your database with phpmyadmin; see http://codex.wordpress.org/Backing_Up_Your_Database You must export and import the database itself - and not do a posts export from the dashboard - to retain all settings, image URLs, etc. Either use phpmyadmin in your host control pa... | How do I copy a wordpress database? | wordpress |
Suddenly one of my custom post types stopped working properly. More precisely, I have a custom post type called Apps where I have a few posts. Everything was working properly until I've created a new taxonomy using a plugin, then I've imported about 2-300 terms using an array in <code> functions.php </code> and then I'... | Have you tried to update your Permalink Settings? That might sort it out. Btw. how did you named your CPT? | Custom Post Type URL doesn't work anymore | wordpress |
I am using a Genesis child theme that I would like to make some custom changes to it, but would like to be able to update it when a new version comes out without loosing my edits. I am familiar with the parent-child practice, but since my theme is already a child of genesis what is the best way to approach that? First,... | From my understanding, there's no grand child theme in current version of WordPress. It's not supported at the moment, but I heard that WordPress will support in future version. So, if you make change directly to your child theme and upgrade, all your changes will be gone. To keep your changes, you can do like this: du... | How to keep my custom theme changes after updating genesis child theme | wordpress |
I'm Doing a site with some content that can be updated by Wordpress, but, It would be a lot times if I could write a php document for one page and other php document for another page, Like front-page.php. Is it somehow possible? Thanks a lot in advance. | I think you are looking for 'page templates'. Try out the codex: Page Templates Page templates allow you to completely change the look of separate pages on your website and still allow dynamic content to be updated by Wordpress. | Specific php document for a page | wordpress |
I followed a tutorial to 'ajaxify' wordpress comments where it does not reload the page: <code> jQuery('document').ready(function ($) { $('#commentform').each(function () { var commentform = $(this); // find the comment form commentform.prepend('<div id="comment-status" ></div>'); // add info panel before t... | <code> <div> <div class="CommentList"></div> <form action="" class="commentForm"> <textarea name="comment"></textarea> <input type="button" value="Comment" class="btnComment" /> </form> </div> <div> <div class="CommentList"></div> <form action="... | Ajax comments not working | wordpress |
I'm investigating WooCommerce as a potential e-commerce solution, however my immediate concern (which I haven't been able to find information on) is the number of products. The proposed store needs the ability to house ~30,000 different products. Is there any technical limitation on the number of products that WooComme... | I hate to mention this on Wordpress.Stackexchange, but I would go with using Magento in place of Wordpress. I love Wordpress and use it on almost every website that I build, but it was not specifically made for e-commerce. Magento handles just about everything better in regards to e-commerce. I only tend to use Wordpre... | WooCommerce store with ~30,000 products | wordpress |
I am trying to pass a variable value to a shortcode attribute. I can't get it to work. Is the following supposed to work, or must values be literal? <code> $mycat = 'books'; $myshortcode = '[products category="'.$mycat .'"]'; echo do_shortcode($myshortcode); </code> The above outputs nothing. If I replace it with <code... | After more probing I found out, that the problem must be with the way HeadWay is parsing the content of the custom code block. I still don't understand it exactly, but changing the code from this: <code> $mycat = 'books'; $myshortcode = '[products category="'.$mycat .'"]'; echo do_shortcode($myshortcode); </code> to th... | problem using $var for shortcode attr value | wordpress |
I have got hundreds of posts published but with inappropriate titles. I want to edit/updates titles. I have those all titles in a .txt file which I want to have them on the posts. If there is any solution?? I want the fastest way. It's also so hard for me to copy/past each title to the post. I want one-click method. I ... | It depends how you produce the titles of the posts but something like: Load the posts into wordpress Update wp_posts using mysql That's how I do bulk editing and it works very well. | how to edit title of bulk posts? | wordpress |
I have a WordPress site which generates a menu at the top of the page with this: <code> <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> </code> This line is located somewhere in a file called <code> header.php </code> . (Location in wp-admin is: <code> App... | You would require the path to <code> wp-blog-header.php </code> to access WordPress functionality in a standalone PHP file. So your <code> justthemenu.php </code> file should contain the following code. <code> <?php require('/wp-blog-header.php'); wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_loc... | Output menu navigation in php file | wordpress |
Okay so I'm using the relationship field from Advanced Custom Fields against a custom post type. The relationship lists countries, when these are saved they are within a serialised array: <code> [country] => Array ( [0] => a:2:{i:0;s:2:"19";i:1;s:2:"72";} ) [_country] => Array ( [0] => field_5049ccf3aac29 )... | Answering my own question, as suggested in my edit I've had to use the following <code> meta_query </code> array to query the posts: <code> 'meta_query' => array( array( 'key' => 'country', 'compare' => 'LIKE', 'value' => '"' . get_the_ID() . '"' ) ) </code> | Querying meta values within an array | wordpress |
Which is the function WP uses to convert words like "voilà" and "novità" to "voila" and "novita" in category slug? Can I recall it in my theme? | If you simply want to covert accented words you can use remove_accents() If you want it converted in a slug like format you can use sanitize_title() | which is the function that removes accented vowels? | wordpress |
After database problems on my provider side, I had to reset my admin user password. But then this user was not an admin anymore. In PhpMyAdmin I see that it has a user_status value of 0. How can I make this user an amin in WP dashboard ? | You actually want to look in the wp_usermeta table. Once in there, look for the entry that has 'wp_user_level' in it's 'meta_key' column and has the matching 'user_id' that you would like to update. Then change that 'meta_value' to 9 or 10. EDIT: updated link to current documentation: http://codex.wordpress.org/Roles_a... | Making someone a WordPress administrator using PhpMyAdmin | wordpress |
Is there a way to remove the link on full size images in posts/pages? I still would like to have it for the other smaller sizes. Since the full size image is already full size, it seems unnecessary to link to itself. | If you're adding the full size image from the Post Editor, when you select the image from the media manager pop-up box, you'll click the button that says "None" under the Link URL field. That would be impossibly messy to control programatically. Well, maybe not impossible, but probably something that you would just hac... | Remove link on full-size images | wordpress |
I was wondering if anyone knew of a paid membership plugin that streamlined the peyment/registration process into a single step. Ideally there would be a signup page. This page would have the typical fields (email address, possibly a user name and password) as well as the paypal button (only active when all required fi... | Membership plugin from Wpmudev.org should fit your needs: http://premium.wpmudev.org/project/membership/ This is step 2 of the registration process with Membership: EDIT: According to comments that membership should give access to certain custom post type i would suggest this: Create a template for that custom post typ... | Paid member plugin with some specific features | wordpress |
I've spent hours trying to figure this out, tried TONS of different methods and all failed in their own way. What I'm trying to do: Limit home page custom post types (woo_estate) to 6 and then paginate the rest. What happens: Not only the home page custom post types don't get limited, no pagination is added. Current te... | I had a double query and that was why nothing worked. <code> var_dump($wp_query); </code> helped me find out about this fact. A lot of the codes I used should have worked in the first place. Once the double query was removed, everything worked again. | Pagination doesn't work for home page custom post type query | wordpress |
I'm using WPAlchemy for a custom meta box that lets you upload media. however the "Add Media" button is taking me to the "add media files to your computer..." as a new page (as if it were just a regular link) instead of opening as a pop-up on the same page. I tested my media upload button in a regular post situation an... | Okay, I solved it (again, cause this happened before but I forgot the solution!).... This was for a custom post type and I hadn't added a support that involved uploading something. So, I added "thumbnail" to the list of supports... <code> 'supports' => array('title','author','thumbnail') </code> for my custom post a... | WPAlchemy MediaAccess "Add Media" button opens new page instead of pop up | wordpress |
This is the code I am using to upload the file to WordPress <code> define(‘WP_DEBUG’, true); $filename = "test.png"; $tmpFile = download_url("http://url.com/testing/crop/".$filename); chmod($tmpFile, 0755); $mimeType = wp_check_filetype($_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename); $file_array = array( 'file... | The <code> move_uploaded_file </code> function is a PHP function: http://php.net/manual/en/function.move-uploaded-file.php One important thing to note about it from that page: This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upl... | wp_handle_upload - The uploaded file could not be moved to wp-content/uploads/2012/09 | wordpress |
I operate a real estate website, and I have a list of homes we are selling. I am using a bunch of custom fields to store information about the homes. When you click on a home in the home listing page (page, not post), it takes you to a dedicated page (again, not post) for that home. I'm very new to PHP and Wordpress. R... | The get_pages function is rather old and really shouldn't be used anymore. Use a get_posts instead (a Page is just a special type of Post): <code> $listingPages = get_posts( array( 'meta_key' => 'streetAdd', 'post_type' => 'page', 'post_status' => 'publish', 'orderby' => 'meta_value', 'order' => 'ASC', )... | get_pages sort alphabetically by meta value | wordpress |
Ola, i am building a complex cinema site, and i want to get movies by date Ex: The movies are aded trought post type, I have a custom field name date. How can i retrive the Movie that shoud play today in cinema ( date in custom field : 08.09.2012...) Ex: How can i retrive the movie by date Site: http://cinema.trancelev... | To be able to query on your dates beyond a simple date comparison you should reverse the format of your date field. Dates should always follow the MySQL date format for reliable querying and sorting: <code> YYYY-MM-DD HH:MM:SS </code> To query movies for today you would use a meta query : <code> $args = array( 'posts_p... | How to get movies by date | wordpress |
Our website has an open system for contributors (WP User Role) to add news and calendar content to the site. I'd like to set and lock the position of the content and meta boxes on the post edit screen. Is there a filter or function to set the order of the boxes before I stackexchange-url ("disable the option of changin... | Found this while trolling the internets... Works Perfectly <code> add_action('admin_init', 'set_user_metaboxes'); //I want it to fire every time edit post screen comes up //add_action('user_register', 'set_user_metaboxes'); //You can also have it only set when a new user is created function set_user_metaboxes($user_id=... | lock meta box position on post edit screen for contributors | wordpress |
I recently updated xampp to 1.8 and enabled xdebug. I'm not sure if this is the reason for this error message which I didn't see before: <code> Warning: fopen(http://api.wordpress.org/plugins/info/1.0/): in C:\xampp\htdocs\wodpress\wp-includes\class-http.php on line 923 </code> Maybe I did something wrong at server con... | That's a warning, not an error. Turn off the PHP display_errors configuration directive. | How to solve the fopen error? | wordpress |
I have Wordpress installed in a classical LAMP configuration. Is there any way to, in a protected environment (like staging), automatically log all database changes (i.e. drop indexes or alter tables) done by a wordpress upgrade process? | Why would you need to log them? They're defined in the code itself. Look at wp-admin/includes/upgrade.php. Every version that changes the DB has a function defined that does the job. The changes made for version 3.4 are defined in the upgrade_340() function. The changes made for 3.3 are defined in the upgrade_330() fun... | How to log database changes during an upgrade? | wordpress |
The plugin "Video Embed & Thumbnail Generator" does a great job of generating thumbnails from videos. It saves the thumbnail URL as metadata for the attachment. The thumbnail gets added to the uploads directory. Is there a way to take this image and add it to the media library so i can pass the image through the im... | here are the pertinant parts that i changed from the kg_video_attachment_fields_to_save() function which filters attachment_fields_to_save: <code> $thumb_url = $attachment['kgflashmediaplayer-poster']; //insert the $thumb_url into the media library if it does not already exist if ( ! ($thumb_id = get_attachment_id_from... | Add image to media library from URL in uploads directory | wordpress |
I'm trying to find a way of adding a single checkbox to one of the existing options pages, most likely options-reading.php programmatically. Unfortunately, I haven't found any good references on this. Any thoughts from the community? | I just did some searching and found this in the codex: <code> add_settings_field( 'myprefix_setting-id', 'This is the setting title', 'myprefix_setting_callback_function', 'general', 'myprefix_settings-section-name', array( 'label_for' => 'myprefix_setting-id' ) ); </code> Here is the link to the codex http://codex.... | Editing options pages? | wordpress |
I have this code: <code> $args=array( 'post_type' => array ('portfolio'), 'orderby' => $orderby, 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => $post_per_page, 'ignore_sticky_posts' => $do_not_show_stickies ); if($pf_categorynotin){ $args['tax_query'] = array( array( 'taxonomy' => 'portf... | I use this function to display comma separated terms from a custom taxonomy: <code> // Get Comma Seperated List of Custom Taxonomy // function the_custom_taxonomies($taxonomy) { global $post; $terms = get_the_terms($post->ID, $taxonomy); $counter = 0; if (!empty($terms)) { foreach ($terms as $term) { echo $term->... | custom post type tags | wordpress |
I successfully managed to create admin bar item using this: <code> add_action('admin_bar_menu', 'toolbar_link_to_mypage', 999); function toolbar_link_to_mypage($wp_admin_bar){ global $wp_admin_bar; $theme_menu = array( 'id' => 'theme_page', 'title' => __('test', 'test'), 'href' => 'http://mysite.com/my-page/',... | You have to create a new array for the new item and pass the <code> parent </code> parameter as the id of this already created item. In your case, the args array should be like this: <code> $args = array( 'id' => 'my-item', 'title' => 'My Item', 'href' => '#', 'parent' => 'theme_page', 'meta' => array( '... | How to add admin bar only page? | wordpress |
This is really starting to look like something that will never get fixed! I've tried EVERYTHING I found on the internet and it doesn't work. The navigations on the pages (more results, 1,2,3 etc.) all fail after the first page. The first page of search results, blog posts, categories and everything works correctly but ... | The problem was not with the theme, upgrading to 3.4.2 from 3.3.1 caused this. | All of the "more results" and navigation links lead to a 404 error | wordpress |
I have my WordPress Media settings set like so . Based on these settings no generated large image should exceed the width of 540px. I embed an image in a post like so . I choose "Large" as a image size, which should have a restricted width of 540px. The end result is an image of 1024x769px. Why won't the image adhere t... | Try uploading the image again now you've set up the media settings, this should fix it. | Images not being generated at correct size | wordpress |
I need to be able to merge two or more posts. What is the exact query (or queries) to make this happen? The scenario is multiple recommendations that need to be merged into one. I have already sorted out comments merging and meta merging. Let's say a user recommends Bill Gates , another one Gates Bill and another one m... | The requirements you are describing require much more of an explanation than is really suitable here. A simple solution might be to mark the duplicate posts as duplicates via a meta box on the post screen. This meta box would have one input: A reference to another post. Check out this tutorial on how to build a custom ... | How to merge two or more WordPress posts? | wordpress |
I've tried to play with db backup and restore but I am dealing with difficulties. This what I've done: I backed up database using cPanel option and got 8MB large SQL file. Afterwards I installed new Wordpress in it's own new home. I accessed database associated with new installation of Wordpress through phpMyAdmin and ... | It sounds like you probably need to go into the wp_options table and change the rows 'site_url' and the 'home_url' to match up with the new location. site_url is on the first page of the wp_options table, and 'home_url' is on the second page. If you can access the wp dashboard those can be changed in the 3rd and 4th te... | wordpress database restore - broken link | wordpress |
I would like to add a "Source" field to my posts form so I can show from where I get the published info. Didn't know if this exists already because I'm just starting with WP. So I do some research and found those: http://wordpress.org/support/topic/add-custom-field-to-each-post http://codex.wordpress.org/Using_Custom_F... | (Just read the third link in your question. It looks like a line of code is missing on step #4. I don't think there's really a need to use the plugin.) There are two ways to do what you are requesting. 1) Learn what a metabox is, or 2) become acquainted with the custom fields box on the edit-post screen in the WordPres... | Adding external field to my post form (admin side) and to post show (frontend side) | wordpress |
I am working on a custom template for my office. I have a static front page and a static home page to display the blog posts. I am having a few minor issues and will have to create a few other questions as I fix each problem... Anyways, this problem is pretty interesting to me. While in development, I have the post per... | It seems this was a noobie mistake. The sticky posts are added to the top of the page thus increasing the post count on the initial blogroll. I just had to remove the sticky posts from being sticky and that solved the issue. I only use the sticky posts for the front page and I do not want them to be at the top of the h... | Home page not obeying post per page setting on the first page only | wordpress |
I'm new to OOP and I'm writing my first plugin. I want to check if the Facebook plugin has already been activated. If so, I want to skip some code: <code> class MyClass { ... function fb_js_sdk_setup() { // Check if Facebook plugin is activated if ( class_exists( 'Facebook_WP' ) ) return; // Continue if Facebook plugin... | You should use <code> is_plugin_active() </code> method to check if a certain plugin is activated. The class 'Facebook_WP' will still exists even you deactivate the plugin. | Check if a class exists within a method | wordpress |
I am using this code to load related posts with a custom taxonomy term slug: <code> <?php global $post; $terms = get_the_terms( $post->ID , 'topics', 'string'); $do_not_duplicate[] = $post->ID; if(!empty($terms)){ foreach ($terms as $term) { query_posts( array( 'topics' => $term->slug, 'showposts' => ... | You need to specify number of posts to retrieve. 'showposts' is how many to show on page, and is deprecated (use 'posts_per_page' instead) <code> 'showposts' => 4, 'numberposts' => 4, </code> | get_the_terms - but only show 4 Posts | wordpress |
I searched for a while but I didn't find any solution. I used the functions stackexchange-url ("listed here"). It outputs something like this: <code> Array ( [0] => 15 [1] => 30 [2] => 50 ) </code> But I want something like this: <code> Array ( [post_id_1] => 15 [post_id_2] => 30 [post_id_3] => 50 ) <... | <code> get_col() </code> function returns only one column as array. To get two column result we can use <code> get_results() </code> , Which will return an array of objects Which further can be converted into required structure using foreach loop. Example - <code> function get_meta_values( $key = '', $type = 'post', $s... | How to get a meta value from all post | wordpress |
I have a theme where I register multiple menus in function.php. All menus have a unique name and a simple description (we just use the name of the theme so they all have the same desc but thats ok). In our templates we use the following code <code> wp_nav_menu(array('theme_location' => 'sub_menu_manager', 'menu' =&g... | The <code> menu </code> parameter is to get The menu that is desired and it accepts (matching in order) id, slug, name. meaning in your case that the desired <code> menu </code> is named <code> Manager </code> but the <code> theme_location </code> parameter as the last word so if no menu is set in that location the men... | What is the $menu parameter used of in wp_nav_menu()? | wordpress |
How would I include a post from a specific category on my homepage in buddypress? Example I have a category 'Homepage Banners' with an ID of 3. In the admin I create a post and assign the 'Homepage Banners' category to it. I then need this to show up on the homepage (the latest post). I am new to WP/BP, any help apprec... | You can also use a new query (with php enabled) so show a single post by ID, i.e. the post with ID 101: <code> <?php $my_query = new WP_Query('p=101'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"&g... | custom post on homepage | wordpress |
How can you filter or alter the search terms that users enter into a search field? Is there a hook available? The idea is to use this function to filter out 2-3 letter "filler" words ("on", "and", "the", etc.) <code> function prepSearchStr($str){ $str=preg_replace('©[^a-zA-Z0-9]©', ' ', $str); $str=preg_replace('©(?<... | You can use <code> parse_query </code> : <code> function wpa64292_parse_query( $query ) { if( isset( $query->query_vars['s'] ) && !empty( $query->query_vars['s'] ) ) $query->set( 's', prepSearchStr( $query->query_vars['s'] ) ); } add_action( 'parse_query', 'wpa64292_parse_query' ); </code> Note that... | altering search terms | wordpress |
Is there a way to have always the <code> the_title(); </code> tag also includes a custom field called subtitle? I want to have a title like this: "subtitle-custom-fild: Posttitle" Like "Cool: The new TV show from Werner Herzog." in this case, cool would be the custom field value, and "the new TV...." would be the_title... | <code> <?php function add_subtitle($title, $id) { $subtitle = get_post_meta($id, 'myCustomField', true); $new_title = $title; if(!empty($subtitle)) $new_title = $subtitle . ': ' . $new_title; return $new_title; } add_filter('the_title', 'add_subtitle', 10, 2); </code> Basically, this uses the <code> the_title </code... | custom field to always to .get_the_title()? | wordpress |
I have been using "if (is_single() && in_category('keyword') )" to display custom links on the sidebar. I was wondering if we have in_tag or any similar function for tags? | Here is the source of <code> in_category </code> function: <code> function in_category( $category, $post = null ) { if ( empty( $category ) ) return false; return has_term( $category, 'category', $post ); } </code> You see, it's actually <code> has_term </code> . This is the same as <code> has_category </code> function... | Do we have In_category like function for tags? | wordpress |
I have a function that I only want to run via a cron job. Is there a way I can check that a particular scheduled event is calling this function and not anything else? | WordPress has a constant <code> DOING_CRON </code> that helps us know we're doing the cron jobs or not. It's defined in <code> wp-cron.php </code> file. So, you can check this constant in your code: <code> if ( defined( 'DOING_CRON' ) ) { // Do something } </code> | Check if function called by cron job | wordpress |
I have moved a theme from local to live and the image URL's are showing my live localhost default url instead of the current live url. Any idea's on why and how to fix this? The site is live at universitycompare.com, then jump to university guide and you will see my problem - incase you wanted something live to look at... | Using Wordpress plugin - Search And Replace This is simple Wordpress plugin, Does database query to replace any content. This plugin can be used to replace a string ( say - localhost:8888 ) with a new one ( domain.com ) . Direct updating MySQL Database - Or, If you've access to MySQL Server you can simply replace the o... | image URL changed in wordpress | wordpress |
I found this code on this site by AshFrame which I added to my functions PHP file and works perfectly to stop one category being displayed on my blog (I have a custom menu so have the category displayed separately)... <code> add_action('pre_get_posts', 'block_cat_query' ); function block_cat_query() { global $wp_query;... | cat takes a comma deliminated list, so '-98,-92' Further reading http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters | Block multiple categories from Blog | wordpress |
I am trying to display data from a custom post type on my home page, for which I am using a separate template. I'm getting a Fatal error: Call to undefined method WP_Query::have_post() when my code looks like this: <code> get_header(); ?> <div class="home_main_text"> <?php while ( have_posts() ) : the_post(... | <code> while ( $loop -> have_post() ) : $loop->the_post(); </code> Your missing an s <code> have_post() </code> should be <code> have_posts(); </code> Your title says retrieving meta-box and I am assuming you mean the post_meta. Which you use the get_post_meta() function. | Retrieving meta-box from a custom-post-type | wordpress |
I have this piece of code: <code> <section class="row row-3"> <section class="column column-1 grid-width-19 grid-left-0"> <section class="column column-2 grid-width-5 grid-left-0"> </section> </code> The first section of the row (column-1) will have variable height depending on the content. The ... | We can do this without touching theme files either by using a child theme or Writing a Custom Plugin , To include only css I'd use plugin rather than a child theme. Example - <code> <?php /* Plugin Name: My Styles Description: My Custom Styles for THEME-NAME */ //Create a `my-style.css` in plugin folder add_action( ... | Equal height sections in custom Headway Theme | wordpress |
I just built a theme that looks for a featured image on the current page, if it can't find a featured image it will continue to look backwards through the family tree until it can find one. Then it will print it. I wrote a little script to accomplish this but it seems inefficient. There has got to be a better way of do... | I don't see anything particularly wrong with it, although I'd probably write the loop like this: <code> $featuredImage = ''; foreach ( $familyTree as $family_postid ) { if ( has_post_thumbnail( $family_postid ) ) { $featuredImage = get_the_post_thumbnail( $family_postid, 'full' ); break; } } </code> A bit simpler to un... | Look Through Family Tree and Find Featured Image | wordpress |
I am trying the way to sort post from custom field numeric value. Here is my query: <code> query_posts( 'cat=2684' ); </code> how to tell to use the custom field "sort_number" value | To sort your posts by a numeric value in a custom field your query would look like this: <code> query_posts('cat=2684&meta_key=yourCFkey&orderby=meta_value_num'); </code> | Sort post by custom field numeric value | wordpress |
Looking through Google Webmaster Tools, I have a lot of 404s for posts with permalink structure of /%year%/%month%/%day%/%postname%/ I have since changed permalinks to /%category%/%postname%.html I thought Wordpress could redirect old post URLs to new post URLS, but the old date based URLs are generating 404s. My .htac... | WordPress doesn’t catch all old URLs, you have to help it. Add the following code to your .htaccess above the WordPress rewrite rules: <code> RedirectMatch permanent /\d+/\d+/\d+/(.+)$ /?pagename=$1 </code> | old permalinks not found | wordpress |
I have modified the function <code> start_el </code> in <code> nav-menu-template.php </code> substituting <code> $item->ID </code> with <code> $item->title </code> so that the html <code> li </code> elements in menu have a more readable class names. In detail, I have changed the line <code> $id = apply_filters( '... | Simply add the following into your <code> functions.php </code> : <code> add_filters( 'nav_menu_item_id', 'wpse64308_nav_menu_item_id',10,3); function wpse64308_nav_menu_item_id( $id, $item, $args){ return 'menu-item-'.$item->title; } </code> | which is the best way to customize nav-menu-template.php? | wordpress |
I am trying to remove the page title (home) from my index page. I made my home page my static page. I am using the skeleton theme https://github.com/simplethemes/skeleton_wp I'm new to wordpress so I hope I'm explaining this right. | I've never used the theme, but the code seems to show that there is an option to hide the title. Line 23 of https://github.com/simplethemes/skeleton_wp/blob/master/skeleton/loop-page.php shows post meta for <code> hidetitle </code> . Look for a checkbox on the edit page maybe? | How to remove title (home) from static page skeleton template | wordpress |
How can i display 3 post types in same page search results. http://cinema.trancelevel.com/ For example i have post_type1-Movies post_type2-Trailers post_type3-Subtitrari Wen i search i want to display the search results.. Ex: i Search for Battleship Movie. I want the search results to display somting like this 1.)The m... | Make sure that your registration arguments for your post types have the <code> public </code> argument set to true or, alternately, <code> publicly_queryable </code> set to true and <code> exclude_from_search </code> set to false . Then, modify your search query by hooking into the <code> pre_get_posts </code> action: ... | How can i display 3 post types in same page? | wordpress |
I don't like the way the taxonomies are displayed within the Wordpress admin and was wondering if anyone knew the best way to hook in and change it. Currently if I select some terms within my post those selected terms go to the top of the list and the hierarchy is broken making it visually confusing for the user. Pleas... | There is a plugin by Scribu called Category Checklist Tree that disables this "feature". | Hierarchical taxonomy UI | wordpress |
I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author? <code> $args = array( 'numberposts' => '1'); $posts=get_posts( $args ); foreach($posts as $post) { setup_postdata($post); //do stuff } </code> | <code> $args = array( 'author' => 1, 'numberposts' => 1 ); </code> The author parameter isn't documented on the <code> get_posts() </code> codex page, but it does work. | How to get single post by one author? | wordpress |
Is there anyway of checking if a password protected post is visible / not visible? I want some thing that says this; If the post is password protected (that parts fine) and the correct password hasn't been entered, then show 'XXX', else show 'ZZZ'. | <code> post_password_required() </code> : whether post requires password and correct password has been provided. <code> <?php if ( post_password_required() ) { echo 'xxx'; } else { echo 'zzz'; } </code> | Check if password protected post is visible | wordpress |
I was looking into using Socialite.js to load my twitter/facebook icons. I found the following tutorial , which helped me to build the desired functionality. The links display, but just as text (with HTML-list bullet points). Everything seems to be in place (css/js/sprite). I know its a long shot, but anybody got any i... | kaiser pointed me to firebug (FF addon) which confirmed what I thought, the css/js files were not being loaded correctly. But everthing seemed ok. I copied the css into my main styles sheet and things started to look better (however, some things still didnt work). I re-did the tutorial (for the fourth time), but this t... | Socialite not displaying icons | wordpress |
I am new at wordpress. I need one header slider plugins like this Please suggest me plugins. I am use "header-image-slider" but it will not display below slider of main image. Thanks in advance | i am use this plugins for the slider thethe-image-slider.1.1.8 and it is very nice and very easy to installed. Thanks and i hope it also help you | Slider Plugins for header | wordpress |
I created a page template, uploaded it, but then changed the template name later. <code> /* Template Name: New Name */ </code> Now, the new template name is showing up on the Page dropdown, but so is the old template name. How can I delete the old one from the list?? | Just remove the old file from your theme's directory. That list of templates is generated from the files present in your theme, so you probably have two files. | remove page template from dropdown? | wordpress |
@Chip Bennet helped me out in a previous question and posted his entire pagination function. This function works perfectly fine for me but I'd like to have custom permalinks in german. <code> /** * Paginate Archive Index Page Links */ function oenology_get_paginate_archive_page_links( $type = 'plain', $endsize = 1, $mi... | I believe the primary reason that the GET parameter format is still used for searches is that search forms are regular GET forms that when submitted form URLs with the GET parameters appended. But a further problem with using custom URLs to capture searches is that search terms can be arbitrary text, including slashes,... | Custom permalink for search and pagination | wordpress |
I've run into a problem using two different twitter plugins. One is for login and one is for displaying a twitter stream. The issue is they both use Oauth so I get a re-declare error when trying to login on my custom login template. Since I only use the twitter stream plugin on profiles I'd like to limit it's functions... | I would approach as follows: Identify all the action/filter hooks in the plugin Identify all scripts/styles being enqueued. Create a function that removes the actions/filters based on the page using <code> remove_action </code> , <code> remove_filter </code> , <code> wp_deregister_style </code> , <code> wp_deregister_s... | How to restrict a plugin from certain pages without editing its core | wordpress |
For dynamic content across a wordpress website, is it a better practice to create new post types for updating content or using theme options? I personally find theme options a little more time consuming to code than registering a new post type in functions.php | It depends on the type of content. Is the content dynamic, likely to change, likely to have repetitions of the same types of information, time dependent? I'll probably use a custom post type. Is the content unlikely to change, or only needs one instance of the information set (like a logo, Google analytics code, social... | Wordpress theme options vs custom post types | wordpress |
I still don't quite understand when it's best to use custom post types vs custom taxonomies.. or both together at once. I have Menus as my custom post type. There's nothing about it that needs to look different from any other post on the site though. What I need to do is display a list of Types of menus (traditional, I... | I like to think of a custom post type as how you define the structure of your content, so menus is a perfect example of how to use a custom post type to structure your post data to be more like a menu. Your need to categorize your menus into different types would be well met by a custom taxonomy. For how to do this, pl... | using custom taxonomies with custom post types: display list of posts by 'category' | wordpress |
So I am making a news website about the future, 2112 to be specific (hello, critics). I wanted to display a post's date to be from 2112. But when I try to do this from the admin panel, it 'schedules' the post. I really want to publish the post in this century. Any help, people? | I had the same issue as you when I was dealing with events and wanted to show future events. Here is what I coded: <code> add_action( 'init', 'change_future_posts_to_post_now' ); function change_future_posts_to_post_now() { remove_action("future_post", '_future_post_hook'); add_action("future_post", 'publish_future_pos... | Display a post's publish date from 2112 | wordpress |
I've recently heard someone say WordPress does send data about your blog to back home. Is that true? and if so what data is that or where in the code can I see what's exchanged? | Yes, it does. See Ticket #16778 wordpress is leaking user/blog information during wp_version_check(). All the details are in <code> /wp-includes/update.php </code> : <code> if ( is_multisite( ) ) { $user_count = get_user_count( ); $num_blogs = get_blog_count( ); $wp_install = network_site_url( ); $multisite_enabled = 1... | Does WordPress send data about your blog to WordPress.org or Automattic? | wordpress |
I've been struggling searching through a bunch of tutorials with no luck. I have a custom login page and am just replacing the login form with the forgot password form on click. My issue is how to get the form to send the user a reset password link if the correct username or email is entered and return an error if not.... | In your plugin you would first set the redirect URL either to nothing: <code> $redirect=''; </code> or the fully qualified URL of the page you want your user to land on after successfully changing their password. For http://example.com/mypage/ you would use: <code> $redirect=site_url( '/mypage/ ' ); </code> Then your f... | Send reset password link to user from custom lost password form | wordpress |
I'm trying to build system, where user can add as many fields as he needs to the post. I'm using code from stackexchange-url ("this") thread. Everythings works fine, except I can't get my upload working. Here's code I've added inside foreach loop in <code> dynamic_inner_custom_box() </code> function: <code> <input c... | Here is how I've done it. No changes to the save function are needed. I've been trying to save data from both fields at once, thats why it didn't worked. <code> <input class="upload_file" type="text" size="45" id="picture_%1$s" name="picture_%1$s" value="%6$s" /> <input class="upload_button button" type="butto... | Metabox with multiple fields added by user and upload box | wordpress |
The problem: I understand how to regularly enqueue jQuery UI in functions.php. My problem is that I'm using a selectmenu widget that doesn't come with WordPress by default: http://wiki.jqueryui.com/w/page/12138056/Selectmenu ...and it only works if I enqueue jQuery using: <code> wp_enqueue_script( 'uicore', 'http://aja... | It's very likely that your test is broken because of conflicts. You are essentially loading two versions of all your UI scripts. That is because the Google CDN version of JQuery UI is not the core , but the entire script library (including datepicker, autocomplete, etc), as opposed to the WordPress scripts, which are b... | Cannot enqueue jQuery correctly using Google CDN | wordpress |
in <code> /www/ </code> I have an <code> .htaccess </code> file containing: <code> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^([^.]*\.less)$ compilers/lessphp.php?file=$1 [R,QSA,L] </ifModule> </code> This code works fine, until I'm requesting .less files in <code> /www/blog/ </cod... | A quick fix could be to change the permissions on your <code> .htaccess </code> file so if you change settings in Wordpress, it'll show you what you need to manually change your <code> .htaccess </code> to since it won't have direct write access to the file anymore. | WordPress mod_rewrite is canceling/overwriting my other mod_rewrite rule | wordpress |
I needed to change the twentyeleven theme folder name, so I activated the default theme, changed the twentyeleven folder name to X, then reactivated it. Everything worked except the menus were all in the wrong places. I figured out they needed to be redefined in Menus> Theme Locations. But now, there's an extra sitemap... | Try going to Dashboard -> Appearance -> Menus and re-applying your custom menus to the appropriate Theme locations. By changing the directory name, you've impacted the <code> theme_mods </code> , including custom menus. To WordPress, <code> /wp-content/themes/twentyeleven/style.css </code> and <code> /wp-content/themes... | changing theme folder name breaks menus - twentyeleven | wordpress |
Basically I'm looking to add this line of code to posts published within the last 24hrs: <code> <span class="new">New!</span> </code> When the post is over 24hrs old, remove the inline HTML element. This is my code so far but have no idea how to implement this feature, anybody got any ideas? <code> <sect... | Compare the current time with the UNIX time stamp of the post date: <code> // now minus one day in seconds if ( ( time() - 86400 ) < get_the_date( 'U' ) ) { echo '<span class="new">New!</span>'; } </code> | Add inline HTML to posts published within last 24hrs | wordpress |
I have a text box in the admin area for entering the names of categories. Right now, this is what is in it events homepage Just like that above. Two categories separated by a space. So now I am trying to get the categories from the database and that is done this way. (I am using SMOF framework) <code> echo $data['exclu... | It's because you've created an array with explode and assigned it to <code> $string </code> , then you're appending strings onto it when you use the <code> .= </code> concatenation operator within your <code> foreach </code> loop. here's a simpler method: <code> $string = '-' . implode( ',-', explode( ' ', $data['exclu... | Problems with explode | wordpress |
I want to a mysql query that matches a page title. Not sure of a better way to accomplish this task, but I am stuck. This is my basic test code. <code> <?php $page_title = wp_title(''); echo $page_title; $test = $wpdb->get_results("SELECT * FROM $wpdb->park_data WHERE park_name = '"$page_title"' ") or die(mysq... | I think if you add a couple of periods before and after the php variable in your query, remove the use of mysql_fetch_array, and use get_row(), it should work better. Here's how I would get a park from your custom table: <code> <?php $page_title = wp_title(''); $park = $wpdb->get_row("SELECT * FROM $wpdb->park... | mysql query from wordpress page using custom table | wordpress |
Kinda confused on this.. hoping someone can help. I have custom post type named "Providers" that I want to pull entries from that are tagged "highlighted". I enabled tag support on the custom post type and then tried using tag=highlighted and tag_id=15 in a new query but it's just showing the hello world post. Here is ... | Ahhh.. not sure why I didn't think to use tax_query. A friend figured it out. Gist is updated. | Query Custom Post Type by Tag | wordpress |
I created a custom-post-type and multiple metaboxes which needs to be saved. I have a function that saves one metabox, but I can't figure out how to reuse this function to save all the metaboxes. <code> add_action ("add_meta_boxes", "add_dedications_jh"); function add_dedications_jh() { add_meta_box('jh_dedicationDate'... | You have to repeat the last 9 lines of your code for the other 2 nonce fields. Consider the following function <code> function wp64123_sanitize_save_meta($nonce_field){ /* Get the posted data and sanitize it for use as an HTML class. */ $new_meta_value = ( isset( $_POST[$nonce_field] ) ? sanitize_html_class( $_POST[$no... | Create & Save multiple Meta-boxes | wordpress |
I want to get the users of role academic and student. I have tried using the code below (passing an array of roles, but all users are being displayed, so clearly it's not working. <code> $roles=array('academic','student'); $args =array('role'=>$roles); $users=get_users( $args ); foreach ($users as $user) { echo '<... | I don't think it's possible to do it with the get_users function. From what the Codex implies, you cannot pass arrays to the role argument. But it should be fairly easy to code your way out of that limitation. Try this: <code> function filter_two_roles($user) { $roles = array('academic','student'); return in_array($use... | Can I pass two roles to the function get_users? | wordpress |
I would like to know if there is a hook that fires when a new CPT is published and its postmeta has been inserted. I was using publish_mycpt but found that the postmeta wasn't being saved at that point. I would like my hook to run only for this custom post type, not for all posts. The function I will be calling via the... | I believe you can do it using the save_post hook, than do a conditional check for the post's post-type and the value of its post meta. <code> add_action( 'save_post', 'do_some_function'); function do_some_function($post_id) { global $post; $post_type_as_taxonomy = array('cpt-1','cpt-2'); // this is your hooked custom p... | Hook when new CPT published AND postmeta inserted | wordpress |
I have this line … <code> <div class="permalink"><?php the_permalink(); ?></div> </code> and the result on my page looks like this … <code> http://mysite.com/whatever/post-or-so </code> I guess it could also look like this … <code> http://www.mysite.com/whatever/post-or-so </code> However I'd like to ... | use <code> get_permalink </code> instead of <code> the_permalink </code> and manipulate it however you'd like via php. | echo post-permalink without http and www | wordpress |
essentially I need to be able to add a class to a post when it show in the list (say index.php) so when in the back end you can say oneCol, twoCol, threeCol and it will then output this within the loop post class. This is to enable a tighter control of the layout. using this line of code for the output? <code> <div ... | Note - I recommend using the hook suggested by @Chip Bennett in another answer Here's the modified version of that filter - <code> function wpse_filter_post_class( $classes ) { $my_post_class = get_post_meta($post->ID, "your_meta_name"); if( $my_post_class != '' ) $classes[] = $my_post_class; return $classes; } add_... | adding a custom css class to post | wordpress |
Good day fine wordpress gurus, I'm having a tough time writing a function that handles the search in a couple of user-selected categories. The way I'm presenting the categories is through the old get_categories method and I'm iterating through the array in order to build a category tree with checkboxes (client requirem... | Sounds like something Relevanssi could handle. With Relevanssi, you'd have the checkboxes to choose the categories. Then, you'd write a function to hook on 'relevanssi_modify_wp_query' filter, where you'd read the checkboxes and convert them to a comma-separated list of category ID's. That you would store in $wp_query-... | Search functionality with multiple categories | wordpress |
We use the Types plugin to setup different custom products for a client. A certain custom post (product) contains some custom fields which is a drop-down select. When creating a new product of this type, the user may select one option from that list. For example, let say that certain product has a custom field of type ... | Just so you know, and after much code sniffing, I finally have a working solution : First, the custom field may start with <code> wpcf- </code> (for example: <code> wpcf-custom-field </code> ). This prefix may be ignored and only the remaining characters kept. As in <code> $customField = substr($fieldName, 5); // $fiel... | Custom field with Types: get custom field's value label (of type select) | wordpress |
I've created a recursive shortcode that looks like this. <code> [tabs] [tab state="active"]Home[/tab] [tab]About[/tab] [tab]Contact[/tab] [/tabs] [tabcontent] [tabpane]Content 1[/tabpane] [tabpane]Content 2[/tabpane] [tabpane]Content 3[/tabpane] [/tabcontent] </code> It is working, but I would like to remove the state=... | Figured out both issues. You can keep a count and find out when you are on the first iteration in the same go. <code> static $count; if(!$count) { $count = 1; $state = ' active'; } else { $count++; $state = ''; } </code> From the PHP Manual. "A static variable exists only in a local function scope, but it does not lose... | Wordpress do_shortcode first iteration | wordpress |
I am setting up a multi-language site using wordpress multi-site and wanted some feedback on the best approach/best practice. I will have the following languages: en, sa, de, ru. en is default. Should the domain.org by default be English, or should domain.org redirect to domain.org/en? | Create a subdomain for each language, set the main site to English. Then use the plugin Multilingual Press to chain these subdomains together. It has an option to redirect the visitor to the correct single page too if it is translated on another subdomain (not sure if that is part of the free version). Subdomains are s... | Should multi-language site using multi-site architecture have default language in base site? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.