question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
In my multisite setup I have multiple environments that I want to share the same database, but use different domains. server1.example.com server2.example.com example.com ... each of those would point to the same database. This works perfectly fine in a standard WP install using <code> define( 'WP_HOME', 'http://server1... | When WordPress loads multisite, it includes the relevant MS specific files in <code> wp-settings.php </code> The relevant lines: <code> <?php // Initialize multisite if enabled. if ( is_multisite() ) { require( ABSPATH . WPINC . '/ms-blogs.php' ); require( ABSPATH . WPINC . '/ms-settings.php' ); } elseif ( ! defined... | Is there a way to define wp_blogs domains in wp-config? | wordpress |
Out of the box, WP eCommerce does not support Meta search. This is a big problem if you are selling books online and need clients to be able to search by the most important Meta tag, Author! Can someone please tell me how I could go about including the meta information search or is there a better plugin that does not c... | You can find a duplicate question stackexchange-url ("here") that has a number of suggestions and references to plugins that will help. | Wp eCommerce meta information search | wordpress |
Now on the front page, in the part with post excerptions I have such a code: <code> <div class="wiadPodtyt"> <ul> <?php $piwa = get_posts( array( 'posts_per_page' => 2, 'cat' => 81, 'post__not_in' => $news_ids, 'offset' => 1 ) ); foreach ( $piwa as $post ) { setup_postdata( $post ); ?> <... | You can make your own function to minimize the characters typed for each time you want to repeat the call to <code> get_posts </code> : in <code> functions.php </code> (perhaps): <code> function print_piwa($postcount=2, $cat_id=81) { ?> <div class="wiadPodtyt"> <ul> <?php $piwa = get_posts(array( 'pos... | How to shorten code with function? | wordpress |
Im currently trying to integrate a superfish menu into my wordpress theme, however it seems to be disappearing. I believe i have coded the js and the css correctly... can someone give me a pointer as to whats up? Or how to integrate into the functions.php FURTHER UPDATE * Ok.... so i put the functions back into my head... | You might want to take a look at the wp_enqueue_script() documentation and modify your code to follow standard WordPress practice. Then look at your output and verify that your JS is being loaded. | Superfish Menu Not Loading | wordpress |
I want to use the <code> wpdb </code> class on my external page not associated with wordpress. I tried to include the following on the php file: <code> // include wordpress functions include( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php'); require_wp_db(); global $wpdb; </code> Now I made a query using <code> $wpdb->qu... | You can't mix <code> wpdb </code> with <code> mysql_fetch_array </code> . They are not compatible. You need to use <code> wpdb </code> methods, plus PHP functions like <code> while </code> , <code> foreach </code> , and <code> for </code> . <code> wpdb </code> does not return the references that PHP's mysql functions u... | Using WPDB class | wordpress |
I have written a plugin named <code> foo </code> , and I want when user typed url <code> /hello </code> and it will display the string <code> world </code> There is an existing psot[1] use the following code <code> if ($_SERVER["REQUEST_URI"] == '/hello') { echo "world"; die; } </code> But this is hacky as it terminate... | So it seems you want to leave it as a late as possible before setting what WordPress should return (in certain circumstances - e.g. when <code> sitemap.xml </code> is being requested). There are two methods - which are broadly identical - but using the WordPress API do varying degrees. The same principal applies to alm... | More gentle way to hook Wordpress custom url | wordpress |
I'm having a strange problem: I've build a category page and want to load up all related posts of a custom post type but won't give any results. I'm using the following code: <code> query_posts( array( 'post_type' => 'blog', 'showposts' => 3, 'cat' => 9 ) ); </code> When deleting the 'cat' it shows all posts o... | Blockquote Taxonomy category with a term with id 9 dosen't have a posts with post type blog . Are you sure that you using native category taxonomy for CPT blogs posts? <code> function query_report($sql){ var_dump($sql); echo '<hr>'; return $sql; } add_filter('query', 'query_report'); query_posts($your_arguments);... | Viewing category won't show up Custom post type posts | wordpress |
I want to create a live demo site like http://www.elegantthemes.com/gallery/ that show themes so when I click on the theme screenshot it takes me to the live theme preview. I tried two plugins themebrowser and wordpress-theme-showcase they are showing the themes in a list and I can click the theme to view, but when I'm... | Solution I used the wordpress-theme-showcaseplugin to show a list of themes in the home page, and to can easily browse the theme that is currently preview I changed the way wordpress handle the permalinks. In the wp-includes/link-template.php file in get_permalink function added this code <code> if(isset($_GET['preview... | Create a live demo gallery for themes | wordpress |
I have just purchased a theme called HQ Photography from themeforest which has a custom post type called <code> gallery </code> . I can add images from my hard drive no problem - but if I click the media tab and select an image the 'Insert into post button' is missing I found a site which suggested I needed to add a cu... | It seems like theme author disabled this fuctionality for certian post type's attachments, for a reason. Trying to get it back could very well break something else. Try contacting theme's author. (S)he will probably provide free support. | Insert into post button missing on custom post type | wordpress |
I was looking at the method below to reorder the Admin Menu Sections : stackexchange-url ("stackexchange-url ...and was wondering if it's possible to reorder the submenu sections using similar method. | Yes there is, but I cannot find a simpler way... Here, we are changing the <code> Media </code> submenu and inverting <code> Add new </code> and <code> Library </code> . <code> add_filter( 'custom_menu_order', 'wpse_73006_submenu_order' ); function wpse_73006_submenu_order( $menu_ord ) { global $submenu; // Enable the ... | Re-ordering Admin Submenu Sections | wordpress |
I am working on a small project for my family to share info, recipes etc. And I added a "@" mention feature. Now that the mention feature works I need to notify the user they were mentioned. I thought that the WP comments already kind of do this and since my family would be getting comment notifications via email I dec... | Turns out the notification email is only sent if the comment_post_ID is not 0. I altered my notification comments code to set the comment_post_ID and now it all works! | How to use filter on comment submission/insert | wordpress |
The shortcode produced by this function - a list of all sites in a multisite - outputs above the content in the loop, no matter where it is placed in the editor. I've looked at the other related questions and answers on WPSE and realize that it has to do with the function using <code> echo </code> instead of <code> ret... | All functions have to return a string, you should not use <code> echo </code> anywhere. Rewrite the functions, use an internal variable to handle the strings and return that: <code> // Output a single menu item function projects_menu_entry($id, $title, $link_self) { global $blog_id; $out = ''; if ($link_self || $id != ... | Shortcode outputs at the top of the_content | wordpress |
I'm looking for a way to only set the width of a thumbnail size and let the height set auto. So if I have two images. One is 600px/420px and one is 600px/600px. I want to set only the width of the thumbnail to 200px so wordpress crops the thumbnails of the above dimensions to 200px/140px and 200px/200px. Any ideas? | In your theme's functions.php file: <code> /* register new image size * 200px wide and unlimited height */ add_image_size( 'wpse73058', 200, 9999, false ); </code> In a template or the like: <code> if ( has_post_thumbnail() ) { the_post_thumbnail( 'wpse73058' ); } </code> | How to crop thumbnail height to auto with set width | wordpress |
Can free plugin on WordPress.org site promote pro-version (not free version) of this plugin? Or it requires special permission from WordPress team? Example: " All in one seo pack " plugin Can one free plugin on WordPress.org promote other pro-version plugin on another site? What type of licence pro-version plugin shoul... | In a nutshell - yes, but be careful about it. Detailed plugin guidelines have some related information (emphasis mine): Trialware is not allowed in the repository. It's perfectly fine to attempt to upsell the user on other products and features, but a) not in an annoying manner and b) not by disabling functionality aft... | Can free plugin on WordPress.org site promote pro-version of this plugin? | wordpress |
Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s <code> functions.php </code> ? There stackexchange-url ("are") stackexchange-url ("many") stackexchange-url ("cases") and many stackexchange-url ("debates") about that topic, mostly because there are some misconceptions... | I would start with this question: Is the functionality related to presentation of content, or with generation/management of content, or of the site, or of the user identity? If the functionality is not related specifically to presentation of content , then it is squarely within Plugin Territory. This list is long: Modi... | Where to put my code: plugin or functions.php? | wordpress |
Each day I manually delete the spam posted on my blog. The comments view allows a maximum of 20 comments in the view. When I have 200 spam entries - I need to click through 10 times to get rid of it all. Is there a way I can view 50 or 100 comments in the wordpress admin window at a time? | Adjust the amount of visible comments in the Screen Options : | Comments view limited to 20 results - any way to increase to 50 or 100? | wordpress |
I have created a function in my plugin <code> myplugin </code> with the name <code> foo </code> , how to call it from the frontend? <code> e.g. index.php? </code> | The same way you would any other: <code> foo(); </code> Active plugins are loaded before the theme files You may want to check that your plugin is activated and the function is available so things dont go pear shaped if you forget to activate it, like: <code> if(function_exists('foo')){ foo(); } else { echo "oh dear yo... | How to call a plugin function from index.php | wordpress |
I am learning how to create custom Wordpress theme from this page and everything is working except commenting system because they haven't described how to enable it (they only used <code> <?php comment_form(); ?> </code> to insert form into template). I can see my comment in the backend but not in the page itself... | Edit your <code> comments.php </code> template and add in <code> <ol class="commentlist"> <?php wp_list_comments(); ?> </ol> </code> This should display comments, pingbacks and trackbacks. See the Codex for <code> wp_list_comments() </code> for help on how to style and separate or to display just comm... | How to enable commenting system in Wordpress | wordpress |
Here's the deal: My plugin automatically watermarks images from the WP gallery on the fly using the GD library wherever these images appear. So, I have a physical copy (in wp-uploads) of these attachments, and also a watermarked, dynamic copy of the image which I replace the image source on the page using Simple HTML D... | I ended up changing my code to this, which is what I needed: Hook in: <code> add_action( 'generate_rewrite_rules', array( $this, 'addRewrites' ) ); </code> Create the rules: <code> public function addRewrites( $content ) { global $wp_rewrite; $plugin_path = substr( str_replace( home_url(), '', plugins_url( '', __FILE__... | Rewriting Image URLs from dynamic to original | wordpress |
so I have this custom post type and taxonomy which i set the rewrite to books because I want the URL to the specific book to be http://domain.com/books/booktitle So this is what I have so far: <code> $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' =>... | I believe you have a problem with the arrays you're passing to <code> register_taxonomy </code> . You have: <code> register_taxonomy( 'book-cats', array( 'books' ), array( 'hierarchical' => false, 'label' => __( 'Book Categories', 'sp-theme' ), 'singular_label' => __( 'Book Category', 'xxr' ), 'query_var' =>... | Help with custom post type and custom taxonomy issue with rewrites | wordpress |
I would like to list my posts by a specific taxonomy. At the same time, for each taxonomy, I woud like to count the number of posts with a specific custom field value. So the list would look like this: for each: custom taxonomy name / count of posts / count of posts in this taxonomy that contains custom post field (key... | The solution is: <code> global $wpdb; $terms = get_terms("TAXONOMY_TERM"); $count = count($terms); if ( $count > 0 ){ foreach ( $terms as $term ) { $querystr = " SELECT count(ID) as count FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT... | List the number of posts for each custom taxonomy and specific custom field value | wordpress |
I am using WordPress comments on a page as a Contact page and I am able to show those comments only to logged in admin. Now I would like to automatically have any comments placed on my Contact page approved. So, in the front end, I can see all comments placed on that page instead of seeing only the approved comments. I... | Considering that in <code> Settings > Discussion </code> you have this options checked: The first is <code> comment_moderation </code> and the second <code> comment_whitelist </code> . Then, it is possible to selectively disable them using the filter <code> pre_option_(option-name) </code> , as follows: <code> add_f... | How to Auto Approve Comments on a Specific Page? | wordpress |
Recently, I change my host server. that causing a problem. When I want upload a new theme or plugin instead of using dashboard uploader want me to enter FTP host and username and password, What I can do to come back to the previous uploader? | If you're on a shared server, it's unlikely your host will correct this issue, but you can add the upgrade constants to your wp-config file so it will at least stop asking every time. | Using dashboard uploader instead of FTP | wordpress |
I have the following code to the shortcode to display a random quote. Question: how to make a button display a new random quote? I mean, that would hit the button and show you a new quote (without refreshing the page of course). <code> function random_quote() { // quotes file $array = file("/path to txt file"); // gene... | First off, this is very borderline within the scope of WPSE, it at all. Apart from the shortcode to trigger the initial HTML output, this is really just AJAX. Anyhow, that being said, this is how it's done: The PHP Assuming that the above PHP snippet you supplied is functional, place the following in a php file for the... | Use AJAX in shortcode | wordpress |
I'm trying to edit the loop in my <code> archive.php </code> template so that when I visit a category page, it only displays the post excerpt and uses the featured image as a thumbnail. When I add <code> the_excerpt() </code> to the loop it displays the excerpt of the first post, but then just keeps repeating it indefi... | the_post - Iterate the post index in The Loop. Retrieves the next post, sets up the post, sets the 'in the loop' property to true. <code> while (have_posts()) { the_post(); </code> after you trigger the_post your the_excerpt shold return different values. | "the_excerpt" in loop just keeps repeating first post? | wordpress |
I'm using a Markdown plugin and trying to write a blockquote Like this But Wordpress converts "> " to an html entity, so the result looks > like this Is there a way to avoid this? | Filtering <code> the_content </code> <code> function wpse72941_content_filter( $content ) { $new_content = ''; foreach( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) { $new_content .= preg_replace( '/^&gt;/', '>', $line ) . '\r\n'; } return $new_content; } add_filter( 'the_content', 'wpse72941_content... | Avoid converting "> " to > | wordpress |
Would be possible to access the protected pages with password through of a token. What I mean I pass the token by URL, is going to be checked if the page is protected, if yes check if the URL has the token than the token to be check if match or not. | The protected post system uses <code> POST </code> so by default, no you can't. However, here is a bare-bone mechanism that will let you do this. <code> function bypass_protected_post() { if (is_single()) { global $post,$_GET; if (isset($post->post_password)) { $bypasskey = get_post_meta($post->ID, 'bypasskey', t... | Wordpress protected Pages | wordpress |
I'm working with a WordPress CMS website that was set up without a blog. I want the site to continue to function as it has, with mostly static pages, including the home page. I want a page called "Blog" to function as a blog. Now I've been asked to add a blog, and what I expected would be extremely easy isn't turning o... | Pogoking's answer helped point me in the right direction, but didn't solve the problem. This is what I ended up doing. I created a new template within the customized theme we are using and edited the blog page to use the new template. <code> .../html/wp-content/themes/[custom theme name]/blogposts.php </code> I added t... | How do I get blog posts to appear within CMS? | wordpress |
I need to know how to make a page template in WordPress that can only be accessed by admins. How could I apply it to the following template? <code> <?php /* Template Name: Agency Area */ ?> <?php get_header(); ?> <div id="body"> <div class="agency_area_menu"> <?php wp_nav_menu(); ?> </d... | <code> <?php /* Template Name: Agency Area */ get_header(); echo '<div id="body">'; global $current_user; if( in_array( 'administrator', $current_user->roles ) ) { echo '<div class="agency_area_menu">'; wp_nav_menu(); echo '</div>'; } else { // echo '<p>You do not have the rights required ... | Allow access to a page for admins only | wordpress |
I've encountered an odd problem and I'm not at all sure how to go about fixing it.. I have a site that was working fine until I changed a page title from "PRESS" to "BLOG." Now, when you visit the blog page , this error comes up: There doesn't seem to be a wp-config.php file. I need this before we can get started. Need... | Looks like you have 2 WordPress installations. One for the main site, other for the Blog. <code> http://parlourdc.com/wp-content/plugins/akismet/readme.txt </code> <code> http://parlourdc.com/blog/wp-content/plugins/akismet/readme.txt </code> If that's not on purpose, you have a <code> blog </code> folder in your site ... | "There doesn't seem to be a wp-config.php file." despite wp-config.php in root | wordpress |
I want to ask that how can i dispaly custom field of a post on a web page . I have used get_post_meta but it resulted in just an array .i cant figure out what is the problem | <code> <?php $meta_values = get_post_meta($post_id, $key, $single); ?> </code> $single (boolean) (optional) If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields. This may not be intuitive in the context of serializ... | how to display custom fields of post on a web page | wordpress |
I'm trying to create a custom post type and would like that post type to have two content blocks. So that in the loop I can ask for content-1 and content-2 separately. I can write the code just having the hard time figuring out how I should start, i.e., is there a way to add another "post content" block easily. Should ... | I would keep the primary content field and add a metabox + a secondary instance of the wp editor (using the handy <code> wp_editor </code> function). Custom field values are stored in the database as <code> LONGTEXT </code> , so they can handle just about anything you wish to throw at them. A class to wrap everything u... | Multiple Content Block | wordpress |
I am using the plugin Sidebar Login for BuddyPress which enables users to insert a login box in the sidebar which in turn produces three links: Dashboard, Profile, and Logout. My issue is that the Profile link, links to the WordPress dashboard. I would like it to link to the actual BuddyPress profile page. Is there any... | There are two ways to do that: From the plugin settings page On the "Loggedin Links" option, the second anchor tag is pointing to Wordpress profile by default: <code> '<a href="http://yoursite.com/wp-admin/profile.php">Profile</a>' </code> . You have to update this to point to Buddypress profile page, to do... | Make Profile link, link to the BuddyPress profile instead of the WordPress dashboard? | wordpress |
I wanted to rename the slug to use a custom rewrite with a prefix or suffix that I choose. For example, if the tag name is "product" I want to use a rewrite with a slug that says "product-powerpint-ppt" so the final URL will look like /tag/product-powerpoint-ppt instead of /tag/product I was looking for a solution to t... | Filter <code> 'term_link' </code> . Sample code, not tested: <code> add_filter( 'term_link', 'wpse_72848_change_tag_slug', 10, 3 ); function wpse_72848_change_tag_slug( $termlink, $term, $taxonomy ) { if ( 'post_tag' !== $taxonomy ) return $termlink; if ( 'product' === $term->slug ) return str_replace( '/product/', ... | How to Create a Custom Slug for Tags and Categories with a prefix or suffix? | wordpress |
I've been using the technique described in stackexchange-url ("this post") to remove the caption and description fields in the uploads modal window, thus eliminating unused clutter for users. Since the title field is already required when uploading images in WordPress, it's easiest for my users to dispense with the alt... | Considering that you will come up with a solution to the accessibility issue pointed by @toscho... Putting a lower priority (later execution) to the filter does the job. $priority (integer) (optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers corres... | How can I remove the image attachment ALT field? | wordpress |
I have recently moved a wordpress website <code> abc.com </code> to <code> xyz.com </code> , And <code> xyz.com </code> functionality is good and working well. And i have created a <code> post </code> with a image in it using <code> Featured Image </code> , and when i <code> publish </code> this post, its not displayin... | I believe there are some root-links that you haven't changed. Please follow these steps Login to admin section www.xyz.com/wp-admin Navigate to settings-> general-> and change the 'Site Address (URL)' and 'WordPress Address (URL)' . Also please check the permalinks and settings-> media there is an upload directory and ... | Images not working using Featured post | wordpress |
Is there a plugin that supports calling custom functions that you've created? Like, page A -- I want to call function x <code> $(document).ready(function(){ call_function_x() }); </code> page B -- I want to call function y <code> $(document).ready(function(){ call_function_y() }); </code> I don't want to write the call... | I would create a custom field containing the function to be called, for example called 'function_to_call'. In the templatefile add the code <code> $function_to_call = get_post_meta( get_the_ID(), 'function_to_call', true ); if ( $function_to_call != "" ) { echo ' jQuery(document).ready(function($){ ' . $function_to_cal... | Call javascript functions from each page | wordpress |
I wanted to add gallery with Thickbox effect(Pop up), i achieved this easily on the posts page by using WordPress gallery and the lightbox plugin.But the theme is custom made there is a footer.php.I don't know how to add this gallery to the footer pro grammatically please help EDIT:Code on Posts Page <code> <a href=... | Since the gallery is rendered via a <code> [gallery] </code> shortcode, you can try using <code> do_shortcode() </code> in <code> footer.php </code> . For example, assuming you want to output a gallery with an ID of 1: <code> <?php echo do_shortcode( '[gallery id="1"]' ); ?> </code> | Adding Gallery to Footer of Homepage | wordpress |
Most well written plugins support a safe means for a developer to customize/theme the plugin by copying PHP files to the theme directory and modifying the copies rather than the original plugin file. But, unless I'm overlooking something, I'm not aware of any that support this with JavaScript/jQuery files. What is the ... | If a Plugin is coded properly, it will: Use core-bundled jQuery, and any other core-bundled script, rather than bundling/using custom versions of such scripts enqueue its scripts, via <code> wp_enqueue_script() </code> , hooked into an appropriate hook, via an explicit function So, for such a Plugin: You won't need to ... | What is the best practice for customizing a plugin's JavaScript/jQuery? | wordpress |
Users on my website sign up through a form (Gravity form) and after they are manually approved they are sent a username (their email address) and a randomly generated password. I would like these users to be forced to change their password when they first login, is this achievable? I took a look at the thread stackexch... | I've put together a quick plugin at https://github.com/lumpysimon/wp-force-password-change in response to your question and a recent client request for exactly the same thing. It adds a user meta field on registration, then checks for the presence of this when a user is logged in. If it's not there, they are redirected... | WordPress: force users to change password on first login | wordpress |
Problem Hi everyone, I have a bit of a problem. I have a function that outputs the avatars of users that follow me . It works great, but if the user is deleted the avatars remain visible as a blank image box with a broken hyperlink missing the users username. Is there any way to get rid of the deleted users avatar from... | When a user say user A is deleted, you're not cleaning up all traces of that user. Namely you need to go into each user following A and remove it from their user meta. This is why your function is showing blank users, because its being given stale information that's out of date, and refers to users that no longer exist... | Remove the deleted users avatar from list | wordpress |
My company is hosting an event where 50 clients will be at an exhibition. I want to create an Ehibitors section with separate admin menu. I want to be able to add Exhibits with custom fields for exhibitor_id, exhibitor_logo_img, exhibitor_title and exhibitor_bio. What is the best way to do this? I dont want to end up w... | This would probably best be solved with a custom post type for the Exhibit. That will give you a new section in the admin-area with posts/pages for each exhibitor. That way you can for example use: Post thumbnail as "exhibitor_logo_img" The post title as "exhibitor_title" The content area as "exhibitor_bio" And if you ... | How do I create a Client Logos section in admin menu? | wordpress |
In my theme functions.php i get code: <code> add_action( 'admin_init', 'my_remove_menu_pages' ); function my_remove_menu_pages() { if(!current_user_can('delete_others_posts')) { remove_menu_page('edit.php?post_type=page'); remove_menu_page('edit-comments.php'); remove_menu_page('edit.php?post_type=slide'); } } </code> ... | I'll guess that <code> admin_init </code> is too early for <code> remove_menu_page </code> , the hook should be <code> admin_menu </code> . | Change role's settings influence post-thumbnail | wordpress |
I've run into a strange problem. I have a custom loop built with <code> get_posts </code> that works fine when loading the page normally: <code> <?php $rows = get_posts(array( 'post_type' => 'drinks', 'numberposts' => -1 )); ?> <?php foreach ($rows as $post) : setup_postdata($post) ?> <?php the_pos... | Try this: function h5b_ajax_get_user_drinks() { return get_template_part( 'drinks' ); exit; } | the_title() and the_permalink() won't work on AJAX calls | wordpress |
I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead. Is this possible? | <code> add_action('init', 'init_remove_support',100); function init_remove_support(){ $post_type = 'your post type'; remove_post_type_support( $post_type, 'editor'); } </code> place it to your themes functions.php | Is it possible to remove WYSIWYG for a certain Custom Post Type? | wordpress |
I've been trying to make wordpress stop adding html tags to my content but leave my own html tags alone? Tried <code> remove_filter( 'the_content', 'wpautop' ); </code> and installed PS Disable Auto Formatting but the problem is that it removes my own html tags aswell? I've tried to get_the_content() and the_content() ... | Try accessing the $post object inside your loop, and echo'ing the content from that. Something like: <code> <?php echo $post->post_content ?> </code> Edit If you need to parse shortcodes, use <code> do_shortcode() </code> : <code> <?php echo do_shortcode( $post->post_content ); ?> </code> | Stop wordpress from adding html tags but not remove my own tags? | wordpress |
Is there a plugin or something that can help me out with deleting unnecessary elements in my code? I am in charge of fixing a WordPress site and have been asked to remove the following elements that are not necessary, for example, I don't have any pagination in my pages but in my code there is still: <code> <link re... | This are default settings fron WordPress. This was set via <code> wp-includes/default_filters.php </code> or the feed inside your theme. Check the theme, <code> functions.php </code> for <code> add_theme_support( 'automatic-feed-links' ); </code> and remove it. Add this via plugin or <code> functions.php </code> in you... | How to remove unnecessary elements in the HTML document head | wordpress |
I am working on getting a copy of a WordPress MU network up and running on my local machine for development purposes (using WordPress 3.2.1 at the moment). I need access to the network administration options. In the usermeta table, I changed my <code> user-level </code> to <code> 10 </code> and <code> capabilities </co... | So, it turns out that those three changes were all that were needed. It also turns out that if any of the serialized arrays are modified incorrectly (which is easy to do when modifying them by hand), the system will just assume you are not a network administrator. Correcting the serialized array for the <code> site_adm... | Add Wordpress MU Network Admin via Database | wordpress |
I want display all my taxonomy terms on the left side of my website, so that when a user clicks on one of the terms he can see the posts according to it. How can I do this? | Create template according Template Hierarchy . Place your design + posts loop inside. To list your custom taxonomy use wp_list_categories | display post according to the term | wordpress |
I have a custom post type called Neighborhoods, which stores information about various neighborhoods of a city. Each neighborhood also has a Facebook page. What I'd like to do is for each neighborhood, use the Facebook Graph to grab the number of likes of the page and save them in the WordPress database to display in v... | First, you'll need to set up a WordPress cron job, and take note of stackexchange-url ("its shortcomings")... Using the Codex example , this is a structure of how this could be done: <code> add_action( 'my_daily_event', 'do_this_daily' ); add_action( 'wp', 'my_activation' ); function do_this_daily() { // 1) Use get_pos... | Save number of Facebook likes to database | wordpress |
Within my loop i'm currently outputting one category that a post is assigned to as plain text. Its being used as a class name within my markup (not visible to users) but if a post is assigned multiple categories, my code below only outputs one category, how do I get ALL categories (that the post has assigned to it) to ... | This is a general solution for all taxonomies. To be used inside the loop (else replace <code> get_the_ID() </code> with post ID ): <code> $taxonomy = 'category'; $terms = get_the_terms( get_the_ID(), $taxonomy ); if( $terms ){ $term_slugs = array_map('esc_attr',wp_list_pluck( $terms, 'slug')); $class = implode(' ', $t... | Display all categories as plain text | wordpress |
This site is part of a Wordpress Network. In the theme's CSS, I'd like to reference some font files using @font-face. The fonts live in the theme's directory. If I use a path like this: http://brinkley.doig.com.au/wp-content/themes/brinkley/myriadpro-boldcond.ttf , the file is not found. The true path is http://www.doi... | It is a googd practice to write references to files from CSS file using relative path to the theme and not one absolute. So, for instance: <code> background: transparent url('images/sprite_phone.png') no-repeat 0 0; </code> Anyway, on your case there is something wrong with the uploaded file, because none of the paths ... | Absolute path in Wordpress Network site | wordpress |
I have a custom post type books and have many meta boxes for it...etc But in the backend, I am not able to search anything. For example I try to search the custom post type id in the search field, it comes back with no results. How can I add different search items into the search query? | Lol, i was just having the same problem :P Well, this plugin is working for me: Search Everything -> https://github.com/sproutventure/search-everything-wordpress-plugin/ or in wordpress plugin page, by name search everything | How to get search results in the backend admin on a custom post type? | wordpress |
I've got a issue when trying to setup our app portfolio. (have a look at our portfolio page ) Whats going on: I created a custom post type with 'apps'. Every post I'm going to create is a project we worked on. In this post there might be 3 properties: 1) App store link 2) Google Play store link ---- optional: ---- 3) I... | Ok, with the use of this 'plugin' ( JareDatch ). It works like a charm. <code> add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' ); /** * Define the metabox and field configurations. ** @param array $meta_boxes * @return array */ function cmb_sample_metaboxes( array $meta_boxes ) { // Start with an underscore to hid... | Custom metabox with App Store / Google Play links | wordpress |
I am trying to add an inline style to my paragraph tags which are ouputted using <code> the_content(); </code> I've tried string replace, see stackexchange-url ("question") I did earlier. But it won't because the_content echo's it and does not return it. If I return the content using <code> get_the_content(); </code> ,... | Thanks to stackexchange-url ("@papirtiger") Came up with this solution just to apply it to a specific content function. I did not explain in my question that I only needed to work on a specific the_content, instead I think the above solutions are a global solutions, and both are great solutions from that point of view.... | How to add an inline style to the tag outputted in the_content() using PHP? | wordpress |
Ok, I've been frustrated about this one: I've got a category page with the Title + Description of the title. Under it I would like to show all the (custom post type, 'blog') posts related with this category and under it related posts of custom post type 'apps'. When applying the following code it only generates all 'bl... | It is 'cat', not 'category'. <code> query_posts( array( 'numberposts' => 5, 'cat' => 9, 'post_type' => 'blog' ) ); </code> Also, be aware the <code> query_posts </code> alters the main page query . Unless you specifically intend to do that, and need to do it, use <code> get_posts </code> or make a new <code> W... | get posts from Custom Post Type & Category | wordpress |
I have configured <code> %tag% </code> for permalinks in wordpress Here is stackexchange-url ("How to use first tag in permalinks"). But while posting multiple tags in a post i am facing a kind of problem. Suppose i have wrote three tags for a post, they are: <code> Backlinks, All About SEO, Web Promotion </code> So he... | There is a column in the <code> term_relationships </code> table for <code> term_order </code> which seems to imply that one could set the order of terms. That said, it looks like it doesn't actually work -- the core doesn't use it in any way. A bit of poking around in <code> wp_set_object_terms </code> , the function ... | Multiple Tags Issue in Permalinks | wordpress |
I'm new to WP so I'm still finding my way around. I want to create a simple list of thumbnails. In html I have done this like so <code> <nav> <ul> <li><a href="images/personal01.jpg"><img src="images/personal01.jpg" /></a></li> <li><a href="images/personal03.jpg">&l... | If this is a post loop can't you just put your images in li's within the editor. Just select them and put them into a bulleted list. | Add thumbnails in 'li' list | wordpress |
Modify the structure of multidimensional array outputed by SQL via $wpdb The output that I need from <code> $wpdb </code> is easily achievable by running multiple queries within <code> foreach </code> . However, I am trying to avoid the same for performance issues. I have two custom tables: <code> items - item_id - ite... | You can do this one of two ways, as far as I can see: Use PHP to combine the current results to the one you want. Basically: $records = array(); <code> foreach( $results as $result ) { $record_id = $result['item_id']; if (empty($records[$record_id])) { $records[$record_id]['item_id'] = $result['item_id']; $records[$rec... | Modify the structure of data returned by $wpdb | wordpress |
Within the section of header.php I have a div structure <code> <div id="header"> <div id="masthead"> <div id="branding"> </code> ... I want to add a div within "branding" - I can do this easily be editing header.php directly. I also think that I can use functions.php to: <code> add_action('wp_head', '... | The <code> wp_head() </code> template tag is intended to fire in the HTML document head , rather than the page header , and is used to output script and stylesheet links and tags, and other similar things in the HTML document head. It should appear immediately before the closing HTML <code> </head> </code> tag, l... | Echo a div to header.php from functions.php | wordpress |
I found examples adding a class to top level items, so we can display an arrow in menu items with sub-items, but is seems terrible to cope with the already built in WordPress classes, can't display the arrow with current and css hover, it just ruins all states. The current nav menu is like this <code> <li><a&g... | This actually creates two instances where it displays a span class within the tag on the primary and secondary levels so you can add different images to your span class for designing and navigating purposes. This helps for users and developers to show if there is a drop-down to your header menu and also makes it easier... | add span class inside wp_nav_menu link anchor tag | wordpress |
I've recently installed the WordPress SEO plugin by Yoast and it's asking me whether to allow it or not to track my blog? Seems like a stupid question on my part but I'm still new on the blogging arena. What do you guys think? What's the difference if I allow it to track me or not? Is there a mutual benefit for the two... | For reference the file that handles the tracking and usage statistics for Yoast SEO is located at, <code> path/to/wp-content/plugins/wordpress-seo/admin/class-tracking.php </code> I have linked to the GitHub repository file in question for further inspection upon which you can see somewhat, relatively, harmless collect... | Allowing Yoast SEO plugin to track me | wordpress |
So I have this custom post type and I have atleast 20 custom meta boxes for it which means there will be 20 postmeta rows. So my question is, since I have that many, would it make more sense to just create a custom table to handle this instead of having 20 separate rows, one for each meta value...etc. I would think the... | Short answer- It Depends Long answer- It's generally faster to query to 1 row in a single table rather than 20 rows of meta information but there are somethings you should cosider 20 custom meta boxes doesn't mean that there are 20 postmeta values. User might be filling only 5 of them & then that would mean that po... | Advice Needed for Post Meta Database Efficiency | wordpress |
Stupidly, I truncated my posts table with out thinking about the term relationships. Now I have a bunch of 404s because there are broken term relationships. Is is possible to rebuild the table with the correct pairings? | If your <code> AUTO_INCREMENT </code> value wasn't reset and your new posts will still have unique <code> ID </code> s and you can do: <code> SELECT tr.*, p.ID FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID WHERE p.ID is NULL; </code> to see which term relationships are orphans and use ... | Is is possible to rebuild wp_term_relationships table? | wordpress |
I'm writing a plugin that takes an xml feed and posts it into WordPress using wp-cron Everything is working dandy, except it keeps adding the same posts over again. So, I'm working on a system to check to see if a post of that title already exists. I've written this, but its always returning 'already exists' <code> glo... | Yes <code> $wpdb </code> is built in and is loaded by the WordPress Core on every page load. I don't see any critical problem with your code. I am going to suggest some improvements because I see some places where could go wrong, but mostly that should work. That makes me think that <code> $article->heading </code> ... | Check if post of title already exists | wordpress |
I am trying to add a <code> rel=next </code> and <code> rel=prev </code> link tags to the head element of <code> image.php </code> template file. I have Wordpress SEO installed and I like to hook to this plugin <code> wpseo_head </code> action hook to achieve that. What I would like to do is to check if the <code> wpse... | You cannot check if an action will be called before that happens. Even if there were already callbacks attached to the action there would be no guarantee the matching <code> do_action() </code> will be used. In your case, test with <code> is_plugin_active() </code> : <code> if ( is_plugin_active( 'wordpress-seo/wp-seo.... | Check if action hook exists before adding actions to it | wordpress |
I have this unchanged code from template-tags.php which links through all of the posts on the site. However I would like to restrict it so that it only links through the articles which are in the same parent category. <code> <nav role="navigation" id="<?php echo $nav_id; ?>" class="<?php echo $nav_class; ?&... | Pass a third argument <code> true </code> to both <code> previous/next_post_link() </code> ( see codex ) | Change next_post and previous_link to navigate throught parent categories only | wordpress |
I would like to add some code depending on which page the users are. <code> <?php $arr = array(2506, 2516,2512,2513,2509,2515,2510,2508,2514,2511,2507); if (in_array(the_ID(),$arr)){ if ($_SESSION['logged'] != 'true'){ echo '<script>document.location.href="./connexion";</script>'; //Not logged so good by... | Assuming that you want to output content conditionally, depending on whether you are on a given set of static pages, by Page ID, you can simply wrap your code in an <code> is_page() </code> conditional. To determine if the current user is logged in, you can use the <code> is_user_logged_in() </code> conditional. For ex... | Add content depending on page loaded | wordpress |
If user is editor , this function auto-shoots when user visits his dashboard! How is this possible? This function should only work when user successfully posts comment, so what is happening? could be wordpress bug? <code> function redirect_after_comment($location) { //This should run only when comment is confirmed. But... | It appears that you're intending to redirect the user to a certain page, after the user posts a comment? If so: why are you hooking into <code> get_commenet_link </code> for this redirect? The <code> get_comment_link() </code> function is intended to return the permalink to a given comment. The <code> get_comment_link ... | Is this a wordpress bug? get_comment_link auto shoots when user visits his dashboard | wordpress |
I'm trying to find out whether there is more than one page of posts (I've set my posts per blog page to 5 in the reading settings) in a custom category template. I would think the global query would have the total number of pages as a property but I can't find the call to it. | <code> global $wp_query; echo $wp_query->max_num_pages; </code> This shows the number of pages for the current query. If you want to determine the actual number of posts found by the current query, you may use <code> $wp_query->found_posts </code> Source:- http://codex.wordpress.org/Class_Reference/WP_Query | Find out total number of pages in global query on archive page? | wordpress |
Is there a way to define a custom post type independent from a theme? All sources I found in the web do that in the theme, fuctions.php or via including other theme-specific php-files. But in my eyes this makes no sense. Where is the separation between content (custom post type) and layout (theme)? An other problem I s... | Is there a way to define a custom post type independent from a theme? Of course, put the Custom Post Type definition in a plugin . Short answer, and kind of obvious, but I am not sure what else to add. | Custom Post Type Definition should not be in the theme - how? | wordpress |
I'm trying to get a random output in the taxonomy archive for my custom taxonomy "areas" I have the taxonomy-areas.php in which I have a standard loop. This one displays the posts from 3 custom-post-types: Hotels Pubs Restaurants As soon as I try to get them randomly with <code> <?php query_posts("orderby=rand"); ?&... | I've finally found the solution thanks to a friend of mine: exploiting <code> get_queried_object() </code> we can set the object name in the script as follows: <code> <?php $obj=$wp_query->get_queried_object(); $args=array( 'tax_query' => array( array( 'taxonomy' => 'areas', 'field' => 'slug', 'terms' =&... | Display custom posts randomly in custom taxonomy archive | wordpress |
in my woocomemrce website i am trying to embade faqs which are generated using a short cut code . these faqs are common for all products which may lead to serious duplicate content issue . how to make only the faqs content to noindex and make the remaining part of the product like description and photos under follow an... | Some spiders honor the <code> <noindex>...</noindex> </code> tags within a page so in that case you could simply wrap your FAQ content with <code> <noindex></noindex> </code> . But I honestly don't know if Google or for that matter which spiders honor the tag. Since this is not really a WordPres... | How to make certain content of the post noindex and no follow. not entire post? | wordpress |
My wordpress blog is set up as <code> de_DE </code> . This means that my login page is also displayed in <code> de_DE </code> . I would like to only have the login page in <code> en_US </code> . So, How would I programmatically change a single page's language? Note : I have WPML but I don't wish to use it, I only want ... | This will need to go in a plug-in, just put the following inside a file ( <code> login-languge.php </code> ) in <code> wp-content/plugins/ </code> <code> /* Plugin Name: Log-in Language Plugin URI: stackexchange-url Changes the language for log-in/register screens only Author: Stephen Harris Author URI: http://stephenh... | How do I change the language of only the login page? | wordpress |
from my header file i can create template path easily for any .js file: <code> <?php $templateDirPath = get_bloginfo( 'template_directory' ) . '/'; ?> <script type="text/javascript" src="<?php echo $templateDirPath; ?>js/scripts.js"></script> </code> but inside the 'scripts.js' file has some inc... | Use <code> wp_enqueue_script() </code> , hooked in via an appropriate action hook callback. <code> wp_enqueue_script( // Script handle 'someScript', // URL get_template_directory_uri() . '/js/someScript.js', // Dependencies array( 'jquery' ), // Version '2.4', // Output in footer? false ); </code> For example: <code> f... | how to create template path for external (include) .js file | wordpress |
I'm facing a problem, basically if I use the tags into the html and then change to visual editor, the tags disappear, and it stays in plain text. Scenario: In HTML mode, I add some p tags to a post I'm editing. I switch to Visual, then back to HTML, and the tag and all of its content are gone. I'm not using any extende... | Wordpress doesn't save <code> <p> </code> tags. Paragraphs are displayed automatically in the TinyMCE visual editor and then the output gets <code> <p> </code> tags automatically (for better or for worse) from the <code> wpautop </code> function. I avoid using <code> <p> </code> tags. A double line br... | When switching from html to visual editor the tag gets erased | wordpress |
Is there such a feature in WordPress, that you have one tag which is the alias for another? Example: Muhammad Ali and Cassius Clay is the same thing. I have two separate tags for each. And I tag my article only with "Muhammad Ali", while another colleague of mine could tag another article which talks about the same box... | You can't do it via the admin UI, but there is an <code> alias_of </code> argument for <code> wp_insert_term </code> which accepts a slug for the term you want it to be an alias of. In practice, I don't know exactly how this works. See this thread from wp-hackers. | Tag with Alias capability | wordpress |
I was reading this article: Common WordPress Development Mistakes and How to Fix Them, and in it, they author says: Getting the theme location: If you are using TEMPLATEPATH or bloginfo( 'template_directory'). Stop! You should be using the very useful get_template_directory() as seen in my examples above. But he doesn'... | To make a long story short: <code> get_bloginfo( 'template_directory' ) </code> and <code> get_bloginfo( 'template_url' ) </code> simply return <code> get_template_directory_uri() </code> . So, you can shortcut that second call simply by referring directly to the latter template tag. Refer to source for <code> get_blog... | get_template_directory() vs bloginfo( 'template_directory' ) vs TEMPLATEPATH | wordpress |
I've seen plugins and snippets on how to set a new default avatar for a site. I'm wondering if this can be done network-wide, such that every new site on the network will have the network's avatar as its primary default. from there the plugin's that allow the user to upload a new avatar will be sufficient to let each s... | In my mu-plugins folder I now have the following code, which adds a custom avatar as the default network wide, but allows each individual site to change it thereafter. <code> <?php /* Plugin Name: Network Default Avatar Description: This Plugin sets the default avatar network-wide */ class Network_Default_Avatars { ... | Set default avatar network-wide | wordpress |
Live site. I've noticed that Contact Form 7 recently stopped working, despite my not having touched any of the settings. What's odd is that I receive neither a confirmation nor an error message; I click "send" and nothing happens. This problem persists across FF, Safari, and Chrome. I read in other, older threads that ... | I just checked your site. There is a javascript error when you submit the form. It looks like the issue is caused by the plugin wp-super-heatmap . Disable that and try it again! If that is not it, start disabling one plugin at a time. I am certain that another plugin causes this issue, and I am pretty sure it is wp-sup... | Contact Form 7 not sending emails- no confirmation, no error | wordpress |
I've got a page template called tpl-memos.php which is attached to a page called 'Memos' with a parent page called 'About', the permalink for the page therefor is example.com/about/memos. On this page a custom post type called 'info' is listing its posts, and this custom post type has a rewrite of '/about/memos' – the ... | What i found was the easiest way to solve this problem – and what i eventually ended up doing – was to build a custom pagination using querystrings. | How do I paginate a custom post type listing on a custom template page? | wordpress |
I am creating a Custom Post Type using a custom plugin. One of the requirement of the custom post type is to be presented in a table layout for print / email purpose. It seems that the logical solution for this situation is to include a specific template file in the plugin which will be used on single Custom Post Type ... | The way I handle these is to store to use <code> template_include </code> to conditionally pass my plug-in template. One of these conditions is that the corresponding file hasn't already been found by WordPress (i.e. isn't present in the theme folder). This means that users can over-ride the plug-in template with a the... | How can I use a file in my plugin as a replacement for single.php on custom-post-type query? | wordpress |
I have "About us" content in a single static wp page and want to show a part of it in the front page with a read more... link. I want to make index.php like this: -Navigation- -About Us - -Some part of About us page content - -Latest News- -The loop for latest news- How can I do the 'about us' part? Thanks | You would use <code> get_pages </code> function or create custom query using <code> WP_Query </code> class. The codex pages have detailed descriptions of parameters for both functions. If this is a theme that you want to release for broader public you would probably want to create a theme options page where user sets t... | How to display text of a page in home or custom page? | wordpress |
How to display attached thumbnail and excerpt (about 200 words) of a page on homepage? <code> <?php $page_data = get_page( 401 ); // Get page ID 401 echo '<h3>'. $page_data->post_title .'</h3>'; echo apply_filters('the_content', $page_data->post_content); ?> </code> I don't know how to display a... | <code> <?php $post_id = 50; // assign post id $queried_post = get_page($post_id); if(is_home()) { ?> <div class='product_title'><h3><a href="<?php echo get_page_link($post_id); ?>"><?php echo $queried_post->post_title; ?></a></h3></div> <div class='product_ima... | How to display thumbnail and excerpt of a page on homepage? | wordpress |
Brunelleschi is based on the Twenty-Ten theme, but has really grown since then. I like my theme, but I'm trying to modify the way a posts in page plugin works and I need to copy the relevant part of the loop to do it. I want to display full posts, but have them cut off at the "more..." spot. In this theme, it says "Con... | It sounds like you need to override the <code> $more </code> default. Do this: <code> <div class="entry-summary"> <?php global $more; $more = 0; the_content(); ?> </div> </code> It is a solution pretty much straight from the Codex . | I can't find the relevant part of the loop in my theme file. How do I find the full content with "More..." | wordpress |
I made a child theme for roots and it worked as expected. I can override everything, including footer.php, but not header.php. My header.php looks exactly like the one from roots at the moment, except for the blog title, which I replaced. I googled it, but it seems that I'm the only one facing this problem. | Just to clarify, are you referring to this theme ? If so, it doesn't appear to use the architecture of a typical theme - you'll need to copy <code> roots/templates/head.php </code> to <code> child/templates/head.php </code> and modify accordingly. | roots child theme can't override header.php | wordpress |
Is there a Wordpress conditional that I can use to check for gallery images/media in a post? I do not want to check if the [gallery] shortcode exist in a post. Attached is a screenshot of what I want to check for and if is images I want to output them to the page. | No Need for SQL queries in the template. <code> function wpse_72594_get_attachments( $id, $mime = '' ) { $args = array( 'post_type' => 'attachment', 'post_mime_type' => $mime, 'post_parent' => $id ); $attachments = get_posts($args); if ($attachments) return $attachments; return false; } </code> Then call the f... | Check if post has gallery images/media | wordpress |
I've got shortcode that needs to include JS library only once and only there where it's used. <code> function shortcode_function($atts, $content = null) { $class = shortcode_atts( array('something' => '0'), $atts ); return "<script src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"></script> And... | Yes, you should use <code> wp_enqueue_script() </code> . The script will be loaded in the footer (action: <code> wp_footer() </code> ). Just once. To inspect the order of available hooks, functions etc. per request try my plugin T5 WP Load Order . | WP_enqueue_script inside shortcode? | wordpress |
I would like to add a button to the WP admin toolbar, similar to the Notifications feature released in Jetpack 1.9.1 (I think it was). The notifications icon is displayed beside the account button, to the right. I am only looking to display a form in the dropdown, for clients to contact me if they have questions - usin... | The following is extracted from Jetpack and enables an identical menu item in the admin bar. Note that: the icon in the title is being pulled from Jetpack's stylesheet the scripts are being printed directly instead of using <code> wp_enqueue_style </code> and <code> wp_enqueue_script </code> . Jetpack uses <code> add_m... | How to make a WP admin button/menu similar to Jetpack Notifications? | wordpress |
Is it possible to choose specific categories that will only be displayed to logged in members? I tried to find a plugin or a PHP solution that does that but could not find anything that was still relevant. | Yes :). The following will effect all queries for posts on the front-end including 'secondary loops' (e.g. post lists on the side) but it won't effect custom post types. So this may not be exactly what you're after, but the principle is the same: <code> add_action('pre_get_posts','wpse72569_maybe_filter_out_category');... | Restrict access and display for categories | wordpress |
I am redeveloping a client's site and, for a number of reasons, in the process changing hosts. I'm developing it on the new host and to get the site orgainised I have attempted to import all the pages from the old site using the WordPress export/import plugins. During the import I checked the "import images" checkbox b... | Although Chip's method may work for some it did not for me. I did get it working however this way: Do the normal export of pages and posts and import them to your new blog (having deleted the original pages and posts) Download the wp-content/uploads folder via ftp from your old site and upload it to your new site, repl... | Import Images from one self-hosted WordPress install to another | wordpress |
I'm trying to write a function to make certain terms of default category always selected. When the user is writing a new post, the term checkbox should be checked and he shouldn't be able to unckeck it. Is it possible? | This can be done with jQuery. In this example, the modifier is printed when editing an existing post ( <code> admin_head-post.php </code> ) and when writing a new one ( <code> admin_head-post-new.php </code> ). There's a condition to check for the correct post type, as this hooks work with posts, pages and custom post ... | How to Make a Category Always Selected? | wordpress |
I am trying to trigger an action in functions.php with the <code> do_action() </code> function, but I appear to need an attribute. The following <code> do_action( 'really_simple_share button="facebook_like"'); </code> does not work... Can you tell me the proper way to make it work (I have tried many other things that d... | The correct way is to pass first argument as a unique string which acts as an identifier for the action & any additional arguments after that <code> do_action('unique_action_tag', $parameter1, $parameter2,,,, & so on); </code> To attach functions to this action you'll do <code> // 10 is the priority, higher mea... | How to use the do_action () with parameter | wordpress |
I am currently following this steps to change server and domain for my website. I have been exporting and importing mySQL from one data base to the other. I am about to delete the mySQL content of the database to replace it. I am scared that it will mess up my website. How does Wordpress create mySQL content on the Dat... | The files on your server are the WordPress app, themes, and plugins. All page, post, widget, user, and plugin data only exists in the database. When you create a page or post, add a user, leave a comment, etc., WordPress is writing that data to the database and nowhere else. When a visitor loads your website, the data ... | How and where is wordpress adding mySQL content to database? | wordpress |
When I make a search, if there is an image title within a img tag, it's displayed in a very ugly fashion among the search results (the whole tag is displayed and the picture too). I found this script which is supposed to solve the problem and this is the only thing I found about the subject over the internet. <code> &l... | I don't know about the code you are trying to use, personally I would never use a solution that excludes results, it's very possible the item being searched for is in those results and excluding them is only a degradation of service. Instead you can use the <code> search.php </code> template file to adjust how your sea... | Strip HTML Tags From Search Results | wordpress |
I have a site with many custom post types and I need a unique slug for each page. What I'm seeing is that wordpress only checks for slug conflicts within a post type before appending "-2", "-3". So I can have "actor/foo", "book/foo", "book/foo-2". I don't want that. I want each foo to have its own slug no matter the po... | A unique slug for posts is done by <code> wp_unique_post_slug() </code> . Looking at the source the returned slug is filtered by <code> wp_unique_post_slug </code> . So we can replace this generated slug with our own. You'll notice in the source that attachments are required to have unique slugs across all types, so we... | Force unique page slugs across all post types | wordpress |
I'm using the following code to display an archive dropdown: <code> wp_dropdown_categories( 'taxonomy=week&hierarchical=1&orderby=name' ); </code> However the format of the taxonomy is week-1, week-2 .... week-10, week-11 I need it to be natural orderered as per http://www.php.net/manual/en/function.natsort.php... | not the best way (at least if you have a lot of tags) <code> add_filter('get_terms_orderby', 'get_terms_orderby_natural_slug',10,2); wp_dropdown_categories( 'taxonomy=week&hierarchical=1&orderby=slug' ); remove_filter('get_terms_orderby', 'get_terms_orderby_natural_slug'); function get_terms_orderby_natural_slu... | Natural sort / ordering wp_dropdown_categories | wordpress |
Looking for a way to make the TinyMCE editor always relative to it's content so that the height of the editor changes accordingly to how much text/images it contains. There seem to be plugins for TinyMCE for this already, but I'm not sure on how to apply it for the Wordpress version: http://www.tinymce.com/wiki.php/Plu... | Here's a solution. There's a slight problem as it does not recognize when images are added to the editor. 1: Create a folder with the name tinymce-autoresize in the plugins folder. 2. Create a file in tinymce-autoresize named <code> tinymce_autoresize.php </code> with this content: <code> function intialize_autoresize_... | TinyMCE Autoresize | wordpress |
I set my "Blog" page to a Blog template I created in Pages (in the dashboard). Also, in Settings > Reading, I set my Home page (home template) as my Front page and my Blog page as my Posts page. However, when I navigate to my Blog page, it shows the home template. Yet, the body class of the Blog page is <code> blog log... | Based on your comment: 1) blog.php What is the file name of your blog custom page template? 2) home.php What is the file name of your front page custom page template? The answer is simple: The <code> home.php </code> file name is a reserved file name in the WordPress template hierarchy , and is used by the template hie... | Blog page won't show Blog template | wordpress |
Lets say i created 2 Different Primary Menus (in the Appearance > Menu .. section). Then in the (Theme Location > Primary Navigation) Section, i can set 1 Menu to be activated. So how can i switch between these Primary Menus at the runtime (Programmatically from the Frontend .. WITH A BUTTON CLICK or something) ? | you can do it on the clientside, if you output both menus and change the visibility on the click of the button via javascript. if you want to do this on the serverside, you could make another template or a <code> if </code> to output the menu you want to show to the user. the only thing you have to change here is the <... | How to switch between the Primary Menus programmatically? | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.