question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I have an existing site that I want to update to 3.5 now, because I want to see if my plugins and themes work in it. I don't want to wait for the full release (when I'll be able to automatically update), and I don't mind that 3.5 is still in release candidate state. I could just copy in all the files from 3.5, but I'm ... | Use the Beta Tester Plugin . Be sure to set it to use bleeding edge nightlies , so that you get the pre-releases. Also: once a new major version is final-released, be sure to change the Plugin's settings back. | Update exisiting site to 3.5 release candidate | wordpress |
I have a website say mysite.com and there is a blog mysite.com/blog.When i post a new post under blog category its appears like mysite.com/newpost.I want the posts under blog category to be displayed under the blog tag like mysite.com/blog/newpost How can i achieve this ? | Set your permalinks to <code> /%category%/%postname%/ </code> . This will set the category name in front of the post URL. If you want to use the fixed string <code> blog </code> , set the permalinks to <code> /blog/%postname%/ </code> . | Putting a Category of posts under a Page | wordpress |
How do you add a script on the footer of the post editor ? I'm adding a meta box under the post editor and I need to include a javascript before the closing body tag (on the footer) How do I achieve this ? The script is not needed on the front-end just on that meta_box (just on the post editor page) | Hook into <code> 'admin_footer-post-new.php' </code> and <code> 'admin_footer-post.php' </code> , check the global variable <code> $post_type </code> : <code> add_action( 'admin_footer-post-new.php', 'wpse_73692_script' ); add_action( 'admin_footer-post.php', 'wpse_73692_script' ); function wpse_73692_script() { if ( '... | Add script to footer - on post editor | wordpress |
Note: This is not the popular question about how to create multiple instances of a widget. I have a text widget that I am using to display "business hours". This text needs to go in multiple sidebars and is likely to change often enough to be a nuisance to change it in multiple places. Is there a way to use the same in... | A possible solution would be to enable shortcodes in the Text Widget. <code> add_filter( 'widget_text', 'do_shortcode', 11 ); </code> Then put the same shortcode (i.e.: " <code> [business_hours] </code> ") in all text widgets, and all of them will display the same content. It's even possible to add some Conditionals Ta... | Add copies of the same text widget instance to multiple sidebars | wordpress |
I'm developing a custom theme that uses several custom image sizes defined in my functions.php like this: <code> add_theme_support('post-thumbnails'); add_image_size('featured_thumb', 175, 120, true); </code> I then get posts from the database and output on a page like this: <code> $featured=get_posts(); if ($featured)... | Remember that custom image sizes are NOT applied retroactively to images already uploaded. Use a plugin like Regenerate Thumbnails or similar to generate them. | the_post_thumbnail('my_image_size') always outputs full image | wordpress |
I have the w3 Total cache plugin installed and so far its been great as I'm sure you will all agree, so thanks to the author for an amazing plugin. However, I used the "empty all caches" button on the general settings page and when the plugin is activated none of my stylesheets are loading so the page appears without a... | W3 Total Cache combines .css files. If you do not want this to happen, deactivate the option on the page <code> wp-admin/admin.php?page=w3tc_minify </code> , section CSS <code> enable </code> . If this option is not available, try setting the <code> minify </code> settings on the main page of W3 Total Cache to <code> m... | W3 Total cache "empty all caches" and no stylesheets render | wordpress |
I'm trying to retrieve the thumbnails for only certain products of my woocommerce, using <code> products_tag </code> , this code is showing all products : <code> <ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 5 ); $loop = new WP_Query( $args ); while ( $loop->... | I found the answer, it was a typing mistake, you have to put <code> 'product_tag' => 'wherever_tag_you_use' </code> and it's works like charm | How to filter all products by products_tag (woocommerce ) | wordpress |
I have the <code> ID </code> from a product ( <code> 1345 </code> ) how can i get the category name of that specific product? I try <code> $post_categories = wp_get_post_categories( $post->ID ); print_r( $post_categories ); </code> but it outputs: <code> Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Array ( ) Ar... | Since the question is tagged woocommerce, i'm assuming that it's a product CPT created by woocommerce wordpress plugin. This answer doesn't apply if that's not the case. The products categories is not normal categories, they are a custom taxonomy created specifically for products which is just labeled as "Categories". ... | Get the category from an ID of a product? | wordpress |
Is there an easy way of getting the charset and collation of the DB tables in WordPress without resorting to SQL queries? | There are <code> $wpdb->charset </code> and <code> $wpdb->collate </code> . I am not sure if or when one of these values might be empty, so it is better to prepare for empty values … From my DB class: <code> /** * Get table charset and collation. * * @since 2012.10.22 * @return string */ protected static function... | WordPress Database Charset/Collate | wordpress |
I want to re-publish all previously published products of a custom post type. Let's say the post type is "events" This is what I was thinking something like this: <code> $args = array( 'post_type' => 'events', 'post_status' => 'publish', // get only published posts? 'posts_per_page' => -1 ); $posts = new WP_Qu... | <code> if ( $posts->have_posts() ) { while ( $posts->have_posts() ) { $posts->the_post(); wp_publish_post($post->ID) } } </code> That should do it. You need the call to <code> the_post </code> to walk through the post set properly. It also sets up the <code> $post </code> object. That should set all of the ... | Making a Custom Post Type Publish Loop | wordpress |
I am developing an events manager for Wordpress. I have post_type = 'event' and taxonomy 'event_place' And I want delete block with taxonomy select in post page, because user can do it at custom metabox. | Use <code> remove_meta_box </code> <code> remove_meta_box( 'categorydiv', 'post-type-name', 'side' ); </code> And hook it to 'admin_menu' as in the Codex . <code> function my_remove_cat_box() { remove_meta_box( 'categorydiv', 'post-type-name', 'side' ); } add_action( 'admin_menu', 'my_remove_meta_boxes' ); </code> I am... | Disable block with taxonomies at post page | wordpress |
I’m having trouble displaying variations in a custom built template, each time i call the wpsc function have_variation_groups() within my loop i get the following php error commerce/wpsc-includes/product-template.php on line 1419 [22-Nov-2012 23:27:39] PHP Fatal error: Call to a member function have_variation_groups() ... | If you look at the default wpsc-products_page.php template, it uses <code> while (wpsc_have_products()) : wpsc_the_product(); </code> instead of have_posts() and the_posts() to setup the loop. The wpsc_the_product() function sets up a global $wpsc_variations object that the product variation functions use. I think in o... | issue displaying variations in custom template using WPeC 3.8.9.2 | wordpress |
Using this piece of code you can show content depending if it's a child-page or not: <code> <?php global $post; if ( is_page() && $post->post_parent ) : ?> This is a child-page. <?php else : ?> This is a parent-page. <?php endif; ?> </code> But I would like to add one more statement, so tha... | I ended up using this code: <code> <?php global $post; $children = get_pages( array( 'child_of' => $post->ID ) ); if ( is_page() && $post->post_parent ) : ?> This is a child-page. <?php elseif ( is_page() && count( $children ) > 0 ) : ?> This is a parent-page (with one or more ch... | Show content if parent page has children | wordpress |
I am trying to use <code> get_transient() </code> method in my word-press ,have read the document and seems like i am doing what has been described in the docs. I need to show Weather in my Website and i am using third part weather API which use to get updated in every 6 hours. we are creating a local cache of weather ... | Catching the weather API remote data The <code> msg </code> , you're showing in your question is basically the result from the weather API. And it says, that there's no data available for your location. The first thing you want to do is some research in the Codex and the "WP HTTP API" . The right/WP way to grab remote ... | Cache remote (HTTP) request with Transients API | wordpress |
Given a wordpress (3.4.x) install that only has 1 admin, how would I grab, from within a plugin, the IP of the currently logged in admin, if there is an admin logged in? In other words: I need to obtain the IP of the admin, IF there is admin is logged in, and use this IP for other purposes. The request will not necessa... | This functionality is not directly available, you'll have to track the logins inside the database(probably as a transient) & check if that transient is available. <code> function check_for_admin() { $user = wp_get_current_user(); if(in_array('administrator', $user->roles)) set_transient('admin_ip', get_ip(), 60*... | Is it possible to get the currently logged in admin's IP? | wordpress |
created this walker below to create a set of tabs. All looks ok but in the source there are several more than there should be causing validation errors. I only want to generate a tab for 'question' post types. code - <code> $mmArgs = array( 'menu' => 'competitionmenu', 'container' => 'div', 'container_class' =>... | Remove the line <code> $output .='</li>'; </code> from your walker. The closing <code> </li> </code> is automatically entered by wordpress for every item. This is done in <code> end_el </code> function of the <code> Walker_Nav_Menu </code> class. | Walker_Nav_Menu creating too many closing tags? | wordpress |
I have a sudomain-based WPMU installation locally with xampp. My <code> vhosts </code> lists domains like follows: <code> 127.0.0.1 mainDomain.com 127.0.0.1 siteA.mainDomain.com 127.0.0.1 siteB.mainDomain.com 127.0.0.1 siteA.com 127.0.0.1 siteB.com </code> The <code> WordPress MU Domain Mapping </code> PlugIn maps "rea... | Multisite cannot be installed in a subdirectory of the document root currently. This will be possible in 3.5. See stackexchange-url ("Multisite on Windows with wildcard subdomains") for a guide how to manage subdomains automatically on Windows with XAMPP. You can stackexchange-url ("move the plugin directory") to anoth... | subdomain mulitsite on localhost in a subfolder | wordpress |
I have a custom plugin 'Charts' that has it's own menu. In that menu are links to the 3 pages for the plugin - 'Charts', 'Add Chart' and 'Edit Chart'. However, I don't want to display the link to 'Edit Chart'. Here is how I add the page in question - <code> $this->pagehook = add_submenu_page('charts', __('Edit Chart... | Use a submenu page as parent slug. The admin menu has just two levels, so the imaginary third level will be hidden. Sample code, tested: <code> add_action( 'admin_menu', 'wpse_73622_register_hidden_page' ); function wpse_73622_register_hidden_page() { add_submenu_page( 'options-writing.php', 'Hidden!', 'Hidden!', 'exis... | Add an admin page, but don't show it on the admin menu | wordpress |
I've search all over for a solution to this but can't seem to find anything that does exactly what I want it to. Basically what I want to do is display a particular div within a post based on the value of a specific custom field. For example; If the value of the "featured" custom field is "1" then I want to be able to ... | Then you need a filter on <code> the_content </code> . <code> function add_conditional_div($content) { global $post; $meta_field = get_post_meta($post->ID, 'your-field-name', true); if (1 === $meta_field) { $content .= '<div>whatever</div>'; } return $content; } </code> The <code> 1 </code> value, of cou... | Show div based on custom meta value | wordpress |
I have this slider(orbit slider http://foundation.zurb.com/docs/orbit.php ) and a wordpress plugin(event manager http://wp-events-plugin.com/ ) that loads all this jQuery-ui stuff( <code> /** * Enqueing public scripts and styles */ function public_enqueue() { //Scripts wp_enqueue_script('events-manager', plugins_url('i... | If you want to enqueue the scripts only on the "Events" page, change the following code to include the conditional tag <code> is_page() </code> <code> function public_enqueue() { //Scripts wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js',__FILE__), array('jquery', 'jquery-ui-core','jquery... | Orbit Slider and Events Manager Plug-in JavaScript | wordpress |
e.g. <code> curl -I http://ma.tt/blog/wp-config.php 200 OK </code> The wp-config.php is not public facing file, since it currently just return blank page, so why not return 404 instead. (so will not be cached by Google) Also, for file such as <code> readme.html </code> , it should be hidden as it disclose your wordpres... | I wouldn't bother with the readme file as probably no hacker bothers to check your WP version before trying to hack into the site. Will not bother with anything in /wp-includes and /wp-admin because I trust the core team to make that code secure in the default installation, and those file don't contain any information ... | How to improve WordPress security by hiding non public facing files? | wordpress |
I have a blog page where blog posts have an excerpt on with a continue reading link below. When the link is clicked the full post should appear/or should be diverted to. This isn't that case. The user is diverted to the post, however only the excerpt is displayed along with a continue reading link which doesn't activat... | You need to use <code> the_content </code> instead of <code> the_excerpt </code> when you display your 'single' post. If you would post your code, you might get a more detailed answer. | How to show a full post, not just an excerpt | wordpress |
all right... I am attempting to create a plugin for my site that adds a js snippet to the head section when a front end page loads. The js is meant to add smooth scrolling to all internal links. First off, the plugin does load the script just fine. It's a snippet from: https://github.com/alextrob/SmoothAnchors Everyone... | Save your JavaScript code out to a separate file within your plugin directory. Then use this code to load the file using the <code> wp_enqueue_script() </code> function. <code> function smooth_scrolling_links() { if ( !is_admin() ) { // Don't load if in the admin screen wp_enqueue_script('Smooth-Scolling-Links', plugin... | JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly | wordpress |
I am creating practice website in which i have "register Here" and "login" link on which I want to open a registration form on click of Register Here and Login Form on click of Login. How can I do this? | Go with Theme My Login . Well written and very functional | Registration and Login form | wordpress |
I'm looking for a complete blank Dashboard. No widgets at all and preferably one column. There are snippets to remove the default WordPress widgets, but haven't found nothing about the ones added by plugins. Searched all over and seems that this hasn't been asked. | From stackexchange-url ("this Q&A"), I've learned about the global variable <code> $wp_meta_boxes </code> . And over there is also the code to remove the default meta boxes . After examining the variable, this is the code I wrote to remove all Dashboard Widgets, including the ones added by plugins : <code> add_acti... | How to Remove ALL Widgets from Dashboard? | wordpress |
stackexchange-url ("In this topic") our friend @toscho created a function that sets the font size according to the number of words in the post. Based on this function, I want to create a custom field whose value will be set depending on the number of words in the post. For example, if the post contains up to 200 words,... | Hook into <code> save_post </code> , count the words, and update the post meta field. Sample code, not tested: <code> add_action( 'save_post', 'wpse_73563_save_word_count', 10, 2 ); function wpse_73563_save_word_count( $post_ID, $post ) { if ( ! current_user_can( 'edit_' . $_POST['post_type'], $post_ID ) ) { return FAL... | Add custom field automatically (add_post_meta) with value based on number of words of article | wordpress |
I am working on a site where the user can do everything from the front end. I am using the plugin from scribu called front-end editor. My problem, is that I have a dashboard page with all the options for the user and I do not want the user to be able to edit it. How do I restrict a page from being able to be edited by ... | From the GitHub-Wiki The <code> 'front_end_editor_disable' </code> -filter Use this filter if you want to completely disable the plugin for certain URLs. Callback arguments: <code> bool $disable </code> : The current state. Default: <code> false </code> You can use conditional tags: Conditionals tags return <code> bool... | How to restrict Front-End Editor on a page? | wordpress |
I want to generate an array of custom post types to add it to a options array. I'm doing this to show a checkbox group populated with custom post type. I have this array: <code> 'options' => array ( 'one' => array ( 'label' => 'Option One', 'value' => 'one' ), 'two' => array ( 'label' => 'Option Two',... | After getting the posts you can easily put them in another array & then return that array <code> function get_sponsors() { $args = array( 'numberposts' => -1, 'post_type' => 'movies' ); $my_movies = get_posts($args); $options = array(); foreach($my_movies as $m) $options[$m->ID] = array( 'label' => $m-&... | populate array with posts | wordpress |
I was wondering how to create a list of categories name and ids for Wordpress Bookmarks such as <code> get_all_category_ids </code> for post. I tried using the <code> get_bookmarks </code> , but the category does not appear in it. Update : Based on advice from @Mridul-Aggarwal, I wrote code that might be useful: <code>... | what about <code> get_terms('link_category'); </code> ? Once you have the objects, you can use them to get whatever information you like. | get_all_category_ids for bookmark | wordpress |
I don't what happened but few times ago its working and now i don't what i did so it stops working, I want its quick fix, Currently when we're adding new post it looks like that screenshot : Column is already 2 and nothing changed when we use 1 column, I want its right sidebar. | I saw this with an older version of WordPress. I have not seen it with more recent updates. You fix is to update, honestly. This should be the least of your reasons to do so. Without updating, the only way I was able to sort it out was by editing the (if I remember correctly) <code> screen_layout_* </code> key values i... | Wordpress admin right sidebar isn't working | wordpress |
How do I load the contents of a text file - or any other file, like .php - and use the test for the <code> login_message </code> hook that prints a message above the <code> #login </code> box in wp-login.php? (BTW, this is in a child theme, if it makes a difference.) <code> function custom_login_message() { $message = ... | Use <code> locate_template() </code> if you want to use a file from your theme. <code> include() </code> or <code> require() </code> works too. Sample code, tested: <code> add_filter( 'login_message', 'wpse_73619_include_login_message' ); function wpse_73619_include_login_message() { print '<pre>'; locate_templat... | Load .txt file for login_message in wp-login.php | wordpress |
I asked this on the Wordpress forum but dint get any replies now I hope I can ask it here. I found the code here My Code is: <code> function exc_custom_taxonomy_dropdown( $taxonomy, $orderby, $order, $hierarchical, $show_count, $name) { $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hierarchical' => tr... | I can kick myself, been struggling for 2 days and all that I had to do to make the wp_dropdown_categories option work is change the name to the same value as the taxonomy. My complete working code is: <code> <?php // Equipment Category Dropdown, thanks https://gist.github.com/2902509 class Walker_SlugValueCategoryDr... | Taxonomy Drop Down with hierarchical view using $terms | wordpress |
Currently I am designing a website that will have alot of content. The site will be build like this: site.com/country/region/city/accommodationtype/accommodation Should I do this in pages and have A LOT of pages. Or... create alot of categories and have the accommodation as a post? Keep in mind that also the country, r... | There are a few possibilities to solve this. The first one, with taxonomies (categories), is not very usable because of the interface to set the category for the accomodation. Additionally, you will have a lot of duplicate categories, as every city will need a subcategory like hotel, b&b, ... Because of this the Se... | Use lots of pages, or categories/posts? | wordpress |
I have a custom page template that pulls in media files via advanced custom fields, as well as query posts. Now, the client wants there to be three sections by default... each one populating with the appropriate images based on another advanced custom field for an image category (which I created). Normally, I would jus... | It's not a hack, this is what databases are designed for- querying large quantities of data. If you're concerned about load, you should employ caching on data that doesn't change frequently. That said, you should not be using <code> query_posts </code> to create additional queries. Really, you shouldn't be using query_... | Is there a better way to pull in custom content without querying posts? | wordpress |
I run a multiple author Wordpress platform where authors post articles where many of them are separated in several pages. The visitors can navigate the pages within the article by clicking on a <code> Next </code> button. This is various types of articles like galleries, lengthy articles, lists etc I am sure you are al... | You can explicitly set the 'like' URL. If you play with the form FaceBook provides you can see how that works. <code> <div class="fb-like" data-href="http://example.com" data-send="true" data-width="450" data-show-faces="true"></div> </code> If you don't set the URL the default is the current URL, so you wi... | Single article separated into multiple pages makes Facebook Like button detect as completely separated articles | wordpress |
I have this shortcode <code> [learn_more caption="something here:"] [/learn_more] </code> I want to extract the caption value and remove other stuff. "something here:" This is the code that I have, but it print the shortcode as it is. <code> $exclude_codes = 'learn_more'; $wp_content = preg_replace("~(?:\[/?)(?!(?:$exc... | Thanks every one for help, actually I solved the problem without using regex at all. I use wp-mpdf plugin with wp-event-manager, when I try to output the event page to PDF some content didn't show like title, and some content, .. and that's what cause the problem, but after some customization I was able to get the cont... | Getting attribute value from shortcode | wordpress |
I want to create a custom page for my Wordpress blog that will execute my php code in it, whilst remaining a part of the overall site css/theme/design. The php code will make use of 3rd party APIs (so I need to include other php files) How do I accomplish this? N.B. I do not have a specific need to interact with the Wo... | Please refer to the Page Templates section of the Static Pages Codex entry . Essentially, you create a custom page template, named something like <code> template-foobar.php </code> , which will live in your Theme's root directory, or in a one-deep sub-directory. Inside this template file, add the following: <code> <... | How to add a php custom page to Wordpress | wordpress |
How do I make a single post page for a single attachment image below and link to it? <code> <?php get_header(); ?> <div id="body"> <?php if (have_posts()) : ?> <div class="page_title"> <h2><?php single_cat_title(); ?></h2> </div> <div class="photos"> <ul class="l... | Refer to the Template Hierarchy for attachment post types : `$mimetype.php <code> $attachment.php </code> <code> single-attachment.php </code> <code> single.php </code> <code> index.php </code> So for an image attachment, name your template file <code> image.php </code> . Then, to link to the single post view for an at... | Attachment image single page | wordpress |
When I use ghostery on chrome, it finds Quantcast, wordpress stats and google analytics on my sites (nathanblack.com and knuckletattoos.com). I have jetpack and google analytics installed, but where is quantcast coming from and how do I remove it? | Quantcast is coming from the Stats component of JetPack. You can: Disable Jetpack Stats Directly block Quantcast, such as via the DoNotTrack Plugin | How do I remove quantcast from my sites? | wordpress |
The laptop I was working on recently crashed. But, I managed to get everything on it backed up, including my recent WordPress project off of my local server (I use MAMP). I uploaded my SQL database and copied the WordPress website folder into my local server. The WordPress login interface looks normal, but after you ge... | I believe the wordpress URL and site URl are not set right. Please try to edit your <code> wp-config.php </code> adding these lines: <code> define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); </code> Is your index on same folder as wp installation? if not, you need to place it there. I'm ... | WordPress Admin Interface not styled properly | wordpress |
Hey all i have been trying to find the content that loads up for a page for a few days now and can not seem to find where its located. This is the WP code that seems to populate the content: <code> if ( function_exists('register_sidebar') ) { register_sidebar(array( 'id' => 'home-top-sidebar', 'name' => 'Home Top... | The content for a dynamic sidebar is whatever widgets are added to that sidebar from the backend. Look at wp-admin-> Appearance-> Widgets. The actual code for those widgets could come from WordPress itself, a plugin, or your theme. But... The content that i am interested in goes inbetween the < div class="visual"> a... | finding sidebar content in wordpress | wordpress |
I have a meta_query that gets all the items with a price range between 2 variables. My problem is that 10 000 is not the same as 10000. How can I fix this? I have been googling but I'n not sure what to google so I'm not really getting anywhere. Help would be appreciated Thanks Hanè Edit - Code Added <code> $kw_min = my... | The problem is that you're comparing <code> 10000 </code> and <code> 10 000 </code> as strings , and as such they are not the same value . So, you either need to sanitize the strings to ensure that both return an equivalent value, or you'll need to force them to be integers, so that they'll be evaluated as the same val... | meta_query results not the same with and without spaces | wordpress |
I'm using a plugin called <code> sidebar-login </code> to display a wordpress login form (it uses <code> wp_login_form </code> ) in my sidebar. However, I feel like it the actual form (textboxes and labels) take up too much space and I'd like to hide it all in a slide-down jQuery div. Basically, the user would click on... | Try using SimpleModal Login . This should be exactly what you are looking for. | Making the wordpress login form a jQuery dropdown | wordpress |
I have a custom template with a drop-down that filters posts by category. I do it by making the form post to the page itself and then catching the argument and using it in a query (see code below). Here's the bummer: if you navigate to page 2 (for example) and then use the filter, the URL still contains the <code> /pag... | Perhaps set your form's action to point to the first page of paged results, rather than the default (empty) of the current page. <code> <form action="_URL_to_first_page_" method="POST"> </code> Keep in mind the URL is determined on the client side in the case of an empty action. | send user to first page of results when reposting to page? | wordpress |
I am using custom posts, and in these, I don't a need for the title. This causes Wordpress to set the titles of my posts to "Auto Draft". I'd like to change the title's value to something else, computed from other fields in my post. How do I go about doing that using save_post or some other means? | I had the exact same need, so I wrote this function - which works. Modify it to your needs. Hope this helps. <code> // set daily rating title function set_rating_title ($post_id) { if ( $post_id == null || empty($_POST) ) return; if ( !isset( $_POST['post_type'] ) || $_POST['post_type']!='rating' ) return; if ( wp_is_p... | Using save_post to replace the post's title | wordpress |
I have the Download Monitor Plugin installed and it works beautifully, I just have a question regarding the categories. I have a parent category, Issue 0, which will have anywhere from 3-6 sub categories in it. Instead of the section on the front page looking like below, where it just lists every download in the parent... | From the documentation and its sample code , I cannot see an option to get the downloads categories tree. The function <code> get_downloads </code> returns a one-dimensional array . Maybe a stackexchange-url ("routine") could be built to convert it into a multi-dimensional array. Use this to see its contents: <code> $d... | Show Heirachy of categories in WP Download Monitor | wordpress |
I am using the following code to generate a JSON feed. I need to extract the excerpt from posts, but when I run get_the_excerpt() it takes 28 seconds (yes SECONDS!) to run on my local server versus 599 milliseconds when I change get_the_excerpt() to 'hi'. Does anybody have any idea why this is taking so long and what I... | The problem will likely be a (very slow) callback that is attached to your <code> get_the_excerpt() </code> function. To inspect the attached callbacks, just inspect the global: <code> // Best hooked to `shutdown` echo '<pre>'.var_export( $GLOBALS['wp_filters']['get_the_excerpt'], true ).'</pre>'; </code> T... | Why does running get_the_excerpt() when generating JSON file take 28 seconds vs. 599 milliseconds without it? | wordpress |
When you use a standard custom field in WP you have to write the name of the cusotm fields the first time. The second time you use a custom field it sticks to the custom fields dropdown list. But, sometimes when you install plugins they ise ALOT of custom fields. This list becomes a bit long an it may "push" som of my ... | You can filter the query for these keys on <code> 'query' </code> . I would start that filter as late as possible to avoid side effect. Sample code, tested : <code> add_filter( 'postmeta_form_limit', 'wpse_73543_hide_meta_start' ); function wpse_73543_hide_meta_start( $num ) { add_filter( 'query', 'wpse_73543_hide_meta... | How to delete custom field "suggestions" from dropdown list | wordpress |
I have added some pages to the WP-Adminmenu, with <code> add_menu_page </code> and <code> add_submenu_page </code> . The URLs for those pages look like <code> admin.php?page=my-plugin/admin/submenupage.php </code> . If I try to add a page now that has isnt registered to the menu and link to it with <code> <a href="?... | The best thing you can do here is to call them with a <code> $_GET </code> parameter, and just register the first site to the menu. so for example, when you registered <code> admin.php?page=my-plugin/admin/submenupage.php </code> , you have the <code> submenupage.php </code> structured like this: <code> if ( !isset( $_... | Admin Subpages without Menu entry | wordpress |
I have a big site for a client, and as it is a really customized wordpress installation with lots of extensions on functionality, I can't use the caching plugins. To improve the performance, I built a lot of the Site using transients (for example the navigation, the google maps with all the markers etc.), and leave the... | For development I would advise to always work with <code> WP_DEBUG </code> set to <code> true </code> and do the following: <code> $key = 'transient_key'; if( !WP_DEBUG && ( false !== ($transient = get_transient($key)) ){ /* Generate transient manually */ $expiration = 24*60*60;//How long to keep for set_transi... | Is there any danger in deleting all transients? | wordpress |
I have development and production versions of my website (on the same hosting). I want to easily synchronize the content between these versions. On the production website, content is updated daily. I cannot use the XML export function because duplicate posts would be created on the development website. Currently both w... | If you never send/sync Production posts to live. Then just pull/copy the live database to the development database via mysqldump (or similar) and use wp-config vars to force the site and blog URL. Use the following in the dev versions wp-config.php to force the URL's <code> define('WP_HOME','http://example.com'); defin... | Merging Wordpress posts from different databases | wordpress |
I am trying to see where I went wrong with this code. I was trying to prepend the avatar and user meta above the admin menu. I get header already sent messages as well since the code is just right under the body tag. <code> function profile_script() { echo '<script type="text/javascript"> /* <![CDATA[ */ (func... | The admin_menu hook is not for displaying the menu, it's actually part of the menu construction process to figure out exactly what goes in the menu, and this is where you should be making calls to functions like <code> add_submenu_page </code> . So when this action is fired, nothing has been printed out yet, there's no... | JQuery prepend a function | wordpress |
I'm trying to create a feed of the most recent 10 posts from 5 different feeds all combined into one list. I found a way to combine the feeds but have not been able to easily limit them to 10 and sort them by date. Can someone point me in the right direction? Thanks!!! <code> <ul> <?php $rsslist = array( 'http... | This code should work. I commented out one of your feeds. When I uncomment it, it stops sorting things correctly. It seems that there is something wrong with it. It doesn't get formatted in the browser correctly like the rest either. <code> <ul> <?php $rsslist = array( #'http://www.pewenvironment.org/rss/campa... | Combining RSS Feeds and Sorting with fetch_feed | wordpress |
It's probably more of a PHP question, but I would like to know if there are any differences in using <code> global $post; echo $post->ID; </code> when compared to <code> echo $GLOBALS['post']->ID; </code> to access the ID of a post in WordPress. This stackexchange-url ("answer") on SO suggests that the first meth... | There is no difference when you are using just <code> echo </code> . What works different is <code> unset() </code> : <code> function test_unset_1() { global $post; unset( $post ); } function test_unset_2() { unset( $GLOBALS['post'] ); } test_unset_1(); echo $GLOBALS['post']->ID; // will work test_unset_2(); echo $G... | Using global $post v/s $GLOBALS['post'] | wordpress |
I want to add 200 videos from YouTube playlist to my WordPress blog. Each video iframe add as each post to particular category. I searched many plugins but that's not meet my requirement. | The Youtube playlist have a xml strema, RSS feed. You can parse this and create post via <code> wp_insert_post() </code> and add as content the URL to the video. Publish this and you have wich each new video from the playlist a new post. The best way is, that you write a custom plugin. But you can aslo use a auto publi... | How can i add all videos from youtube playlist as post? | wordpress |
QapTcha is a draggable jQuery captcha system. I have been trying to create a plugin to make it work on the Wordpress comment system. I found a plugin that is already doing this but it is outofdate and doesn't use the latest QapTcha version. The earlier versions do not function on touch screens, therefore, the latest ve... | First things first, there is quite a bit of <code> _doing_it_wrong() </code> in the script enqueueing. Don't override core-bundled scripts Try removing this hook callback, and see if that fixes things: <code> function my_scripts_method() { wp_deregister_script( 'jquery' ); wp_deregister_script( 'jquery ui' ); wp_regist... | Adding a slider captcha to the comment system | wordpress |
Is it possible to remove custom post types from WP_QUERY that have a same shared custom taxonomy so that only one custom post type associated to that custom taxonomy is returned? Example: Get an Items custom post type, returning only one Item per a custom taxonomy. On a taxonomy-types.php page, I'm using WP_QUERY to ge... | Thanks guys. I think I may have found a solution. What I did: On <code> taxonomy-types.php </code> , get all Items for that type using WP_QUERY. Loop through them, use <code> get_the_terms() </code> to get taxonomy Model for each Item Still in the loop: use PHP's <code> in_array() </code> function and a <code> $model_i... | Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY? | wordpress |
I have a custom post type called campsites, events and activities I want to display this in a list. So when the user click on the link, it will then display all the posts under that custom post type. Any help would be greatly appreciated. Edit <code> add_action('init', 'activity_resources_register_post_type'); function... | Create custom page template The first step is to create a custom page template to hold the code. For example, name the file <code> template-cpt-list.php </code> : <code> <?php /** * Template Name: Custom Post Types List */ get_header(); // Custom code will go here get_footer(); ?> </code> Create list of generated... | Display custom post type in template | wordpress |
Is there a built-in function that would allow me to restrict access to registered users until the official launch date in Wordpress 3.4.2? The blog is self-hosted. | This should do it. Place it in your theme's <code> functions.php </code> or a plugin. <code> function tst($a) { if (!current_user_can('edit_posts')) { wp_die('You are not allowed to view this page'); } } add_filter('template_redirect','tst'); </code> You can still get to the login page like normal by going to "/wp-logi... | Restrict access to specific users | wordpress |
So I have many custom user profile fields. When I use <code> do_action( 'show_user_profile', $profileuser ); </code> hook it displays all custom user profile fields.. But I would like to show only certain fields. For example <code> add_action('show_user_profile', 'add_extra_profile_fields1'); function add_extra_profile... | You could either find the hook that is outputting all those extra fields and use <code> remove_action </code> on it. Or you can just create your own hook: <code> do_action( 'my_theme_show_user_profile', $profile_user ); </code> | frontend show edit profile with selected custom options | wordpress |
I have been searching for a while, this. I want to add an item via AJAX. When you add an item to a cart in Woocommerce the page reloads with the GET parameter <code> add-to-cart="The current product ID" </code> . I want to do it via AJAX. In the admin area is a checkbox to enable that featured that is labeled "Enable A... | are we talking about the single product view or the product archive pages (shop,categories)? because the text beside the checkbox/option states, roughly translated: »activate ajax-checkout-button on product archive pages« and on all the installations i did so for, that is the way its working - ajax checkout on the arch... | How to add to cart via AJAX Woocommerce | wordpress |
I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel. function retrieve_my_terms() { global $terms; $terms = get_terms('taxonomy'); foreach ($terms as $term) { $option = $term-> name; return $option; } } The function is added after the functions which created the custom post type... | You can add the action on the init itself, just increase the priority of the <code> add_action </code> call. The higher the priority the later the function is called. <code> add_action('init', 'retrieve_my_terms', 9999); </code> But my suggestion is that you should do these kind of things as late as possible, preferabl... | Using get_terms for custom taxonomy in functions.php | wordpress |
The Problem: I am currently in the finishing stages of a premium theme I've been developing and all is mostly well. For pages I have a few custom meta boxes for adding in slideshows and other additional pieces of page content and have found that the editing screen is now pretty long. Due to the large vertical height yo... | Solution based in stackexchange-url ("this StackOverflow Q&A"). Well, more a proof of concept than anything... Style and scripts being printed the lazy way. Add a fixed <code> Scroll to top </code> div linked to an anchor near the <code> Publish </code> button. <code> add_action( 'admin_head-post.php', 'scroll_to_t... | Editing Screen: Make Update or Publish Button Follow The Page | wordpress |
Im integrating Superfish into WP. I have called the CSS and the JS. However when I place a class style in the <code> wp_menu </code> as below, the menu is disappearing ( see here for rendered output ). Could anyone assist (this has been followed from a not so helpful tutorial ) Current code being generated is: <code> &... | Looking at your rendered output: <code> <div class="menu sf-menu"><ul><li class="page_item page-item-2 current_page_item">... </code> It appears that <code> 'sf-menu' </code> got appended as a class to the menu container , rather than to the menu itself . The <code> wp_nav_menu() </code> function has ... | Specifying Class style for Menu | wordpress |
Is there a way to replace a function by another function in a child theme? In other words, in a theme there is a function named "theme_function" and this function is called by several files inside the theme. I would like to find, if exist, an action that replace all occurrences of "theme_function" with another function... | If the parent-Theme function in question isn't either pluggable (i.e. wrapped in a <code> if( ! function_exists( $function ) ) </code> conditional) or filterable (i.e. returns its output wrapped in a <code> apply_filters( $filtername, $output ) </code> ), then there's no easy way to override the function. You'll have t... | Replace function in a child theme | wordpress |
I want to show all my post taxonomies on the left side of the web page in such a way that when a person click on it the post can be displayed according to the taxonomies.is there anyway to display them and i also want to add some style in it. | You can build a list using two functions: <code> get_terms() </code> and <code> get_term_link() </code> : <code> <?php function wpse73271_get_term_archive_link_list( $taxonomy ) { // First, get an array of term IDs $term_objects = get_terms( $taxonomy ); // Now, loop through $term_ids and get // an array of term arc... | List of taxonomy archive index page links | wordpress |
Let me know whether <code> wp_is_mobile </code> function will work with all the mobile and tablet devices ? Is it enough to check mobile device ? I found that this method in <code> wp-includes/vars.php </code> <code> function wp_is_mobile() { static $is_mobile; if ( isset($is_mobile) ) return $is_mobile; if ( empty($_S... | No, it will fail. There are literally thousands of mobile clients, and not all send a usable User-Agent header. There are stackexchange-url ("better ways") to adjust the site to small screens (which is not necessary the same as mobile! ). Use client side detection and offer a link to switch the view; save that option i... | wp_is_mobile function | wordpress |
I'm creating a script that automates build a wordpress site from another CMS. I've been able to change every setting: themes, options, subdomain, site title, etc. But what is eluding me is being able to create custom menus. The code below SHOULD be able to do it for me. However it is not, and I am completely stumped on... | <code> $wpdb->insert( $wpdb->term_relationships, array( "object_id" => $thisMenuItem, "term_taxonomy_id" => $menuID ), array( "%d", "%d" ) ); </code> This was missing from the Question code. It allows the menu items to bind to the navigation menu itself. | wp_update_nav_menu_item not saving in multisite API | wordpress |
I'm not able to configure Simple Facebook Connect v1.5 correctly. The plugins admin panel tells me that: No User or Access Token found. Try re-saving this page. Application Access Token not found. Try re-saving this page. Fan Page Access Token not found. Try re-saving this page. But according to the documentation my co... | Turns out the issue is browser related (FF 16.02). Using Chrome authorization works fine. But there are still more issues when the Facebook user is not logged in (tokens are not correctly stored locally). So I have settled for the " Add Link to Facebook " plugin. | Simple Facebook Connect: Access tokens not found | wordpress |
I have a custom post type called 'camps', and in there I have different categories ie derbyshire, staffordshire etc. I have created a template archive-camps.php for this. archive-camps.php works fine when we go to www.domain.com/camps but if we go to www.domain.com/camps/derbyshire it uses the default archive.php Why d... | From Codex: taxonomy-{taxonomy}-{term}.php - If the taxonomy were sometax, and taxonomy's slug were someterm WordPress would look for taxonomy-sometax-someterm.php. In the case of Post Formats, the taxonomy is 'post_format' and the terms are 'post-format-{format}. i.e. taxonomy-post_format-post-format-link.php taxonomy... | Custom Post Type Archive.php | wordpress |
I'm developing a plugin with an options page using the Settings API. I'd like to have one options array stored for my plugin, but on the settings page, I'd only like some of the settings to be visible to admin users, but the full list of settings to be available to the super admin. Is this possible? | Test the current user’s role with <code> current_user_can( 'administrator' ) </code> : <code> if ( current_user_can( 'administrator' ) ) { add_settings_field( /* arguments */ ); // or add_settings_section( /* arguments */ ); } </code> Make sure to use the same check when you save the options. Otherwise your regular use... | How to display some settings for super admin user only using Settings API | wordpress |
I have the following code in my functions.php <code> $code = 'EUR'; global $wpdb; $query = 'SELECT * FROM '; $query .= $wpdb->get_blog_prefix() . 'fxbase '; $query .= 'WHERE code= '.$code; $data = $wpdb->get_row( $wpdb->prepare( $query ), ARRAY_A ); </code> The problem is the above query does not give any resu... | Your specific issue in that code is that you're missing the quote marks around the $code. <code> $query .= 'WHERE code= '.$code; </code> Should be: <code> $query .= 'WHERE code= "'.$code.'"'; </code> In the long run, you should indeed use prepare() properly, but this is the specific problem with the code you posted. | Wordpress $wpdb no result | wordpress |
I am retrieving some images post with: <code> $img = wp_get_attachment_image_src( $attachment_id, 'full' ); </code> How can I retrieve the image title? Thanks. | In WordPress attachments are stored as posts so you can use most of the post specific WordPress calls and functions to read/write data associated with the attachment. This applies to post meta data for an attachment as well. So in this case, since you have the post ID ( same as $attachment_id ) you can simply use the <... | wordpress get gallery images title | wordpress |
I would like to inject some elements directly after the <code> <body> </code> tag. Is that possible using only WordPress hooks? | Just add a custom hook to your template: <code> <body> <?php do_action( 'wpse73370_custom_hook' ); ?> </code> | How to inject content after | wordpress |
We have custom post type as <code> user_images </code> and each of these post has a image attached with image name is 3 digit number followed by extension. When the url <code> http://mysite.com/wp_username/3digitnumber </code> is accessed, we want to use a custom template inside theme to show the image Tricky part is t... | As I mentioned in your other question, you don't want to be touching the .htaccess file, you need an internal rewrite. So, given the URL: <code> http://mysite.com/image/wp_username/3digitnumber </code> we need to add the following rule to handle it: <code> // set up the rewrite rule function wpa73374_setup_rewrites(){ ... | Tricky URL rewrite with custom values in url | wordpress |
Just like I customize the CSS print for a page, I want to be able to convert the page to PDF. Many plugins I tried just display main content of the page or post without design; just plain text. I want to be able convert the page to PDF as it is. Is there a way to do this even without a plugin? | WP-MPDF has always worked extremely well for me and has a decent templating system you can override. Thanks! | Convert Wordpress pages to PDF | wordpress |
After installing/activating AWPCP (Another Wordpress Classified Plugin), when I type wp-admin/ I get a blank page but with /wp-login.php the login appears. I this there's a problem with redirection or .htaccess with that plugin but I can't find out what it is. | the plugin is causing a 500 error but php debugging is turned off. The fix it, FTP into the server and remove the plugin then your admin will be back up and running. | After activating a Plugin, /wp-admin is no longer accessible | wordpress |
I am running a simple wp query to retrieve just one post. But the post is a custom post-type post, not a normal post <code> $ajaxBike = $_GET['varbike']; $bikeProfile = new WP_Query(array( 'name' => $ajaxBike, 'meta_query' => array( array( 'key' => 'app_visibility', 'value' => 1, 'compare' => '=' ) ) ));... | <code> 'post_type' => 'custom post type slug' </code> By default 'post_type' is set as 'post', you will need to specify your custom post type in any query you make. In future refer here: http://codex.wordpress.org/Class_Reference/WP_Query | WP query by custom post type slug/name | wordpress |
I upload thousands of images and it stored in a single folder. Is it bad if too many images are in a single folder? would that slow down the loading of the image even though you're viewing an attachment image which has a path defined? | No the depth of your directory structure has almost no impact to load time. Maybe if your structure is very depth and the URLs for the images are very long you can hit the stackexchange-url ("maximum length") or your markup blows up. But a flat hierarchy should not be a problem as long as you keep the file names short ... | Is it bad to store many files in a single folder? | wordpress |
I want to display a dynamic sidebar on all pages, and a different sidebar on the homepage. There are also particular pages where I don't want to display either of them. This code is not hiding the unwanted sidebar off of the Homepage; both sidebars show. How can I hide 'multipackage' from the homepage and only display ... | I want to display a dynamic sidebar on all pages, and a different sidebar on the homepage. There are also particular pages where I don't want to display either of them. This code is not hiding the unwanted sidebar off of the Homepage; both sidebars show. How can I hide 'multipackage' from the homepage and only display ... | How to display different widgets on specific pages, hide from other pages | wordpress |
I have a custom walker that extends the Walker class. My code uses the Walker_Page class as it's base as it does pretty much everything else I want but I need to modify it a bit so that it behaves a little differently. Essentially, I want to prevent the walker from creating new levels of navigation for menu items that ... | I accidentally left out an important detail in my question that made it a little more complex to solve. I also wanted to show sub navigation of the current page if it had children. I did this by comparing the element's ancestors to the current page's ancestors (as well as the current page itself), if there wasn't any m... | How to prevent custom walker from creating sub navigation for pages that are not relatives of the current page? | wordpress |
I just recently noticed in my backend admin panel none of the dynamic JavaScript links will open or work at all. This includes the 'Edit' links next to Status, Visibility, and Scheduled. Also the slug permalink edit button will not do any Ajax/JavaScript. Clicking any of the links will just append the hashtag value (ex... | you should check out the other posts related to this. A lot of times you will have some type of malware in Wordpress coded in PHP which screws with your JS codes. I have seen other threads on stack about similar points.. JavaScript widgets do not move and no ajax edits. Check out stackexchange-url ("this stack thread")... | wp-admin post.php JavaScript Links Not Working | wordpress |
I have a series of posts that are ordered by a meta_key value. They could also be arranged by menu order, if necessary. The next/prev post links (generated by <code> next_post_link </code> , <code> previous_post_link </code> , or <code> posts_nav_link </code> all navigate by chronology. While I understand this default ... | Understanding the internals The "sort" order of adjacent (next/prev) posts is not really a sort "order". It's a separate query on each request/page, but it sorts the query by the <code> post_date </code> - or the post parent if you have a hierarchical post as currently displayed object. When you take a look at the inte... | Can the Next/Prev Post links be ordered by menu order or by a meta key? | wordpress |
I am using the NextGen gallery WordPress plugin for a site. In my gallery.php template I want to retrieve the number of images for each gallery displayed in the loop. I cannot figure out a way to get the data and print it under the thumbnail of each gallery that's called in gallery.php Here is where I want to insert th... | Using your above code, you were just missing the WHERE clause. Hopefully that should work. <code> <?php global $wpdb; $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = {$gallery->ID}") ); ?> <a rel="prettyPhoto" href="<?php echo $image->imageURL ?>" &... | NextGen - Display Image Count Per Gallery | wordpress |
My clients wants to see the changes i have made in his wordpress site before publishing. Is it a good method, paste the page preview link to show to him? Of course this method only works if we are both logged in the Panel Administration. Otherwise what how do you recommend to do? I can not physically meet up my client ... | Password-protect and publish the page and send your client the password. | Show preview posts and pages to clients | wordpress |
I'm having a really difficult time with this. I have a multi-user gallery site. Each author has his own page that lists the author's posts (this is a custom post type). I have made it so that the author url(author.php) is www.example.com/firstname-lastname/. But when a visitor clicks on one of the author's posts, the u... | You can use the <code> %author% </code> tag in the <code> rewrite </code> property in <code> register_post_type() </code> . However, although the rewrite rules are added (after they're flushed) - WordPress doesn't replace the tag with its appropriate value when generating the permalink of your post type. For instance y... | Display posts with author in the url with custom post types | wordpress |
I've built a site with a custom post type called Testimonials and am using a custom template to display the posts edit: template name is page-testimonials.php . All is working as expected with the default permalink structure, however when I set the permalinks to /%postname%/ the custom template is ignored and the posts... | Custom post types have a different hierarchy than pages or posts. They'll use <code> single-{{post_type}}.php </code> and fall back to <code> single.php </code> . Post type archives will use <code> archive-{{post_type}}.php </code> and fall back to <code> archive.php </code> . Your question isn't super clear, but if yo... | custom post template ignored after altering permalinks | wordpress |
I have the following snippet of code, basically I get the set value of id from the metabox, get the current id based on the loop, try and match, if htey match I want to pull the values from the matched id, currently i can only get the id, but i would like to get the associated custom field values of that post as well. ... | You're setting <code> $id = $post->ID; </code> outside of the loop for <code> agent_type </code> posts, it'll never match. Anyway, if you're not doing anything with the <code> agent_type </code> posts that don't match, just query for the one post you want by its ID: <code> $list_agent = get_post_meta( $post->ID,'... | Help with if statement inside while loop | wordpress |
I need to add multiple checkboxes to a post comment form (a Woocommerce product review form, to be exact) that allows people to choose which health condition the product is best for. Upon choosing X number of checkboxes and leaving a written comment, I need those values stored in the commentmeta table as an array. Then... | Make the <code> input </code> names array elements: <code> <input type="checkbox" name="condition[]" </code> PHP will convert that on the fly to a real array before you get access to the values. | Storing Comment Meta as an Array | wordpress |
I have a custom post type with several taxonomies within it Eg. the post type is called <code> campsites </code> and the taxonomies are various <code> counties </code> : cheshire, staffordshire etc. What I want to do is: list all of the counties and when you click on a county it links through to a page which lists all ... | There are plenty of functions for grabbing the data you need, a quick look at the Codex function reference reveals many useful functions you can use to build this. Use <code> get_term_link </code> to get the link to that terms archive, and <code> wp_get_object_terms </code> to get the terms of an object/post. To get al... | Listing taxonomies from custom post type | wordpress |
The scenario is this: An agent enters the post data (custom post), but can only do a pending for review or change the visibility of the post. He cannot change the post status manually. I have achived the pending for review, but I cannot hide the "Status: published/pending etc. Edit". How is it possible (if possible)? | Add this code where it's should be (plugin/functions.php/mu-plugin) - simple "hide" method using css. <code> add_action('admin_print_styles-post.php', 'hide_publishing_block_using_css'); add_action('admin_print_styles-post-new.php', 'hide_publishing_block_using_css'); function hide_publishing_block_using_css(){ echo '&... | Prevent users from changing post status | wordpress |
I'm trying to use shortcode in my page, I'm starting with a simple test. In <code> functions.php </code> : <code> function HelloWorldShortcode() { return '<p>Hello World!</p>'; } add_shortcode('helloworld', 'HelloWorldShortcode'); </code> In <code> index.php </code> : <code> [helloworld] </code> This doesn'... | Referering to the Shortcodes API you can do <code> echo do_shortcode('[helloworld]'); </code> if your shortcode not in post. Or you can do <code> echo apply_filters('the_content', '[helloworld]'); </code> but this will also bring other filters to work on your shorcode return html. | Using shortcodes in PHP | wordpress |
In contact form 7 email settings, I put in all the necessary details like below: However, when the e-mail is sent, it still has the "Wordpress" title or person who sent it in gmail: What am I missing? Did I set something up wrongly? Any piece of advice or information would be highly appreciated. Thanks! | In the field "From" you can enter both a name and e-mail like this: <code> YOUR-NAME <email@example.com> </code> Or with info from the form it self: <code> [name-field-name] <[email-field-name]> </code> | Contact Form 7 - E-mail message template | wordpress |
When I update or upgrade my site automatically ,it corrupted. How can I update or upgrade it safely and manually? | A "Manual" install involves downloading the WordPress zip and extracting it to your site directory (via ftp or a file manager like cPanel has). make sure your <code> wp-content </code> folder is fully backed up as you will need it. then run the extract. | How can I upgrade wordpress with manual? | wordpress |
I feel like this is going to be one of those slap yourself on the head questions, but here it goes anyway: I have a multi-dimensional array of data: <code> Array ( [0] => Array ( [id] => 1033 [zip] => 27604 [distance] => 0 ) [1] => Array ( [id] => 1024 [zip] => 27615 [distance] => 6 ) ) </code> ... | There was a stackexchange-url ("similar (related) question") on here recently. The upshot is that <code> get_the_title() </code> uses the <code> global $post </code> when no argument is passed. And <code> setup_postdata() </code> doesn't set that <code> global </code> (a mistake I've made before now ). In your case, I ... | Using setup_postdata() with multi-dimensional array | wordpress |
My business partner and I are developing several plugins and we want to know if there is a standard for the version number of a plugin when there are updates, i.e., version 1.0, version 1.2, version 1.2.3, etc? Thanks for any advise. | No, there is no standard. You can even use names, roman numerals or whatever, but I would not recommend it. Most authors use Semantic Versioning : <code> Major.Minor.Patch </code> . This has several drawbacks: Users are afraid of “big changes”. Upgrades for a new version with a change in the first part ( <code> Major <... | Is there a standard for naming plugin versions | wordpress |
I'm trying to pull the content from a post/page into a template file. I'm using the following code, which works fine HOWEVER the content is pulled in regardless of whether it is set to 'live' or 'draft'. Is there a way of checking to see whether the post is live before pulling in the content? <code> <?php show_post(... | Your custom function <code> show_post() </code> uses <code> get_page_by_slug() </code> to retrieve the specified page. Looking at source , it doesn't look like <code> get_page_by_slug() </code> uses <code> post_status </code> . So, you'll need to query <code> $post->post_status </code> within your <code> show_post()... | Check to see if post is live before displaying the content | wordpress |
I have several custom post types and we need to create separate archive templates for these. I tried the following advice, but it's still using the default archive template. In the form of the single-type-template. In the same way that posts are shown on their own page with single.php, custom post types will use single... | For custom post type with slug <code> camps </code> : Single post template: <code> single-camps.php </code> Archive index template: <code> archive-camps.php </code> | Archive template | wordpress |
I want to create a blog to share with my family, but random Internet strangers should not be able to read the posts. How can I make posts hidden to the public, by default? I know I can manually edit the visibility of single posts while I edit them - one at a time. Is there some global preference setting that I could se... | I finally found something (I think): Network Privacy is currently in version 0.1.4 but looks just about right. When installed, there's a new Privacy setting screen where I can choose, e.g. I would like my site to be visible only to Site contributors. Given that new users automatically get the permission level Subscribe... | How can I make my blog private? | wordpress |
I am using the Transients API to hold the output for a gallery plugin's shortcode I created. Due to the number of images used and different layouts needed, the transient name looks lik the following: <code> _transient_galleries_single_shortcode_5183five </code> So - the <code> int </code> portion is the post ID it is r... | Forgot I could go this route: <code> $wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_galleries_%')" ); </code> | Using a wildcard with delete_transient() | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.