question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
Hi this may look a little silly question but can someone let me know where is the location for theme_path? is it inside my own theme or very top level of the directory? <code> 'menu_icon' => theme_path . '/images/product-icon.png', </code> A : www.awebsite.com/images/product-icon.png B : www.awebsite.com/wp-content/... | It's not entirely clear what you are referring to here. Judging from your code <code> theme_path </code> looks like a constant. Usually when supplying/printing links to theme assets you would use <code> get_bloginfo('key') </code> with one of the keys <code> template_directory </code> or <code> stylesheet_directory </c... | Location of theme options page menu icon | wordpress |
I have some menu items in a menu at location "main-menu". By using <code> wp_nav_menu( array( 'theme_location' => 'main-menu' ) ); </code> , i get all the 13 items in a div. Now i just need to show 10 menu items in present div and the remanining in other div (say id="new") just adjacent to it. Again if the div with ... | Besides a custom walker, you could also use a filter, such as <code> wp_nav_menu_args </code> or <code> wp_nav_menu_objects </code> as described in the codex | How to gain access to each menu item in wordpress? | wordpress |
I'm trying to find a way of duplicating an existing Wordpress site that uses a custom theme to a new domain. Once it's there I'll do a redesign of the site and redirect the old url to the new one. Just briefly... I tried following the instructions @ http://codex.wordpress.org/Moving_WordPress but when it told me to "3.... | If it's a new domain, it's pretty simple: Install WordPress on the NEW domain Copy <code> wp-content/themes </code> and <code> wp-content/plugin </code> from the OLD domain to the NEW domain (using FTP) Activate the Theme on the NEW domain Activate Plugins on the NEW domain Delete generic content (hello world post, abo... | How to copy an existing (custom themed) site to a new domain | wordpress |
I set my 'About' page as home page, its permalink (my_site/about/) became my_site/ as a result. Is_page('about') returns TRUE on my local server but FALSE on online server. Why is that ? | You can use the function is_front_page() . Put this where you want to check if is frontpage <code> if( is_front_page() ) { echo 'I am the frontpage'; } </code> It returns TRUE when the main blog page is being displayed and the Settings-> Reading-> Front page displays is set to "Your latest posts", or when is set to "A ... | Testing if current page is the static page set as home page | wordpress |
I have one weird thing happening with lightbox on my website. If I add a lightbox image or gallery and then click on the image, the first time it will navigate directly to the image file. If you then click the back button and click the image again, lightbox loads up normally. Any thoughts on why reloading the page afte... | Its just you. I tried from fast internet computer and it loads fine the first time. Then I tried from a low speed computer before the page completely loaded, and it acts the way you described. So its all about loading and fast internet connection | Weird lightbox phenomenon | wordpress |
I have WP Super Cache installed, and compression is turned on. However, both GIDZipTest and Google Page Speed Insights Chrome extension say that compression is not enabled. I added the following to my .htaccess file, and they still say compression is not enabled: <code> AddOutputFilterByType DEFLATE text/plain AddOutpu... | W3 Total Cache is working; compression is being performed correctly. | WP Super Cache compression not working | wordpress |
I need to find an archive of some Wordpress plugins. Previous webmaster of the site installed some plugins and then made modifications to some of them. He did not document these modifications in any way, so I have no idea what was changed and where. There's also no contact with him. And now I need to upgrade Wordpress ... | If the plugins were hosted in the official WordPress SVN repository, you can download old versions directly if they're available by clicking the 'developer' tab on the relevant plugin page. e.g. http://wordpress.org/extend/plugins/buddypress/developers/ (scroll down to 'other versions'). If the plugins weren't hosted a... | Wordpress plugin archive | wordpress |
I am using Events Manager Plugin Javascript is not working on Submit Events Page . I found the reason behind this , that was, I have written a line of code in functions.php to call jquery file. <code> wp_enqueue_script('jquery-1.7.2',get_template_directory_uri().'/js/jquery-1.7.2.min.js'); </code> When I remove this li... | You're enqueuing a specific version of jQuery. It's better to enqueue the version that comes with WP, like this: <code> wp_enqueue_script('jquery'); </code> in a function run by the hook <code> wp_enqueue_scripts </code> | javascript is not working on Event Submission? | wordpress |
the template function as a callback argument of <code> wp_list_comments </code> function, and the template function takes three args: <code> $comment, $args, $depth </code> , like the template function that defined in the theme <code> twentyeleven </code> 's functions.php, <code> function twentyeleven_comment( $comment... | Well, I have the solution. first, use the global variable $comment_depth, pass it to <code> twentyeleven_comment() </code> function, and in the <code> twentyeleven_comment() </code> function, define a new variable named <code> $defaults </code> like this: <code> function twentyeleven_comment( $comment, $args, $depth ) ... | How to call wp_list_comments() with callback outside the loop | wordpress |
can anyone help me split this custom post type into two lists? i'm a novice PHPr but have been left with this code by someone who said it was too complicated... <code> function listforcontinent($name, $top = false){ // top=true - show name, no columns // top=false - dont show name, columns $slugname = sanitize_title($n... | You could count the number of items and insert <code> </ul><ul> </code> after 50%. Sample code, not tested: <code> if ($postslist) { $count = 1; if($top) echo '<h4>'.$name.'</h4>'; echo '<ul>'; foreach ( $postslist as $post ) { echo '<li><a href="'.get_permalink($post->ID).'"&g... | Split custom post list into two columns | wordpress |
I am using <code> get_comments('status=approve&number=5') </code> to display recent comments in my wordpress sidebar. I need to display the recent comments of a particular category. How to do this? | In this link , there is the following code that addresses your question: <code> // Posts per page setting $ppp = get_option('posts_per_page'); // either use the WordPress global Posts per page setting or set a custom one like $ppp = 10; $custom_offset = 0; // If you are dealing with your custom pagination, then you can... | get recent comments of a particular category | wordpress |
My code is so simple like when admin delete a post by Wordpress fucntion (PHP) and do action with jQuery <code> <?php include('../../../../../../wp-config.php'); if(current_user_can('edit_posts')){ $id = $_POST['ID']; wp_delete_post($id); }else{die();} ?> </code> This is my code , what are you think about securit... | At first, read something about WordPress Ajax API and about Roles and Capabilities - capability to "edit_posts" has even Contributor . I would suggest to check for 'delete_others_posts' to prove the user is at least Editor. Or use capability of 'manage_options' (has Administrator, not Editor). Further, there is a check... | Security to delete post by Admin | wordpress |
I'm using a great little open-source product called Restler to provide a RESTful API to a Wordpress application. In order for this to work I want to be able to load the Wordpress environment within a set of PHP classes that Restler will run when a request comes in. The idea of loading the WP environment -- without the ... | The credit for this answer really goes to @Wyck who correctly identified the source of the problem. Thank you very much. The reason for the problem is: There is a variance between an import statement in the mainline code versus within a function. In WP or in in any of the plugins if variables aren't explicitly set to g... | Including Wordpress in RESTful API | wordpress |
Currently my permalink structure for posts is <code> domain.com/post-title </code> I'm using a static front page and a "blog" page for posts. I'd like to to change the permalink structure for posts, tags and categories to <code> domain.com/blog/post-title </code> I can easily add /blog/ in the permalink structure but t... | When you register your post type , the <code> with_front </code> argument of <code> rewrite </code> should be <code> false </code> , so the permastruct is not appended to the front of your custom post type permalink. <code> $args = array( // snip... 'rewrite' => array( 'with_front' => false ), // snip... ); regis... | Change permalinks for posts but not for custom post types | wordpress |
Hey i get this error messages on my localhost setup, but only with the genesis framework enabled, wordpress twentyeleven works fine. This does happen when i want to create a new post. If i refresh the page the error will repeat but the post itself gets crated and it seem everything goes fine. Does anyone know what caus... | You have found a bug in Genesis. Your Xdebug stack trace fingers the culprit as the <code> genesis_save_custom_fields() </code> function which calls <code> current_user_can() </code> with a singular capability (edit_post and edit_page) which also requires an additional argument, in this case the post ID which is missin... | Undefined offset: 0 in > [...] /wp-includes/capabilities.php on line 1067 | wordpress |
I'm looking for a custom permalink plugin that is able to interact with menu classes. For instance, I have a menu that includes the parent <code> website.com/shop </code> as one of its list items. If a page, say <code> website.com/shop/product </code> , includes that menu, the list item for <code> website.com/shop </co... | Here was the final solution I came up with. I spent a lot of looking into whether I could change the the custom post type "product" to hierarchical and set its page parent appropriately so that the menus would add the correct ancestor classes naturally. But I hit a road block and eventually came back to a solution base... | Custom Permalink Plugin and Current Page/Ancestor in Menus | wordpress |
Recently, I've noticed there is a category/ tag name "Contests" added to the title of all of my pages. I've checked the "Tagline" under "Settings" > > "General" of course, it hasn't changed. This is what's in <code> header.php </code> and I have never touched it at all: <code> <title><?php wp_title(''); ?>&... | I've found the cause. All in one SEO Pack plugin 1.6.14.5 is guilty (perhaps it's not guilty by itself but also due to the multisite setup of my site and other plugins I've just installed conflicting it). Disabling the plugin resolve the problem immediately. I'm upgrading it and will use an alternative if it doesn't wo... | Why is a category/ tag name prefixed to title of every page? | wordpress |
I have installed wordpress Muilit Site (NETWORK) I need to Remove / Rename <code> Uncategorized </code> Category In Wordpress. How is this possible? | To change the default "Uncategorized" using code you can do the following: <code> // Uncategorized ID is always 1 wp_update_term(1, 'category', array( 'name' => 'hello', 'slug' => 'hello', 'description' => 'hi' )); </code> Read this: http://codex.wordpress.org/Function_Reference/wp_update_term | Remove / Rename Uncategorized Category In Wordpress | wordpress |
What is the difference between the <code> wp-uploads </code> directory and the <code> wp-content/uploads </code> directory? I am running Ubuntu Server 12.04 and recently installed WordPress using apt-get, but there have been a few problems. Most of the install went into <code> /usr/share/wordpress </code> including a <... | Well, after lots of digging (before and after posting this question), I think I figured it out. As @s_ha_dum suggests, the reason behind the odd directory placement is likely a personal preference of the person who created the Ubuntu "wordpress" package. Perhaps it makes for easier partitioning of permissions, or it ma... | Using wp-uploads instead of wp-content/uploads | wordpress |
I got this shortcode for display my blog posts on my page, but the EXCERPT and the COMMENTS are displaying on the top of my page. Anyone has any ideia why is doing that? <code> /// Recent Blog Posts add_shortcode('recent_blog_posts', 'shortcode_recent_blog_posts'); function shortcode_recent_blog_posts($atts) { $str = '... | You use the function <code> the_exerpt() </code> , replace this with <code> get_the_excerpt() </code> . I don't know for sure, but you might need to use <code> apply_filters('the_excerpt', get_the_excerpt()) </code> to maintain the formatting in wich <code> the_excerpt() </code> is returned. Try to use <code> get_comme... | Shortcode displaying at the top of the page | wordpress |
I created a custom post type, of which the (simplified) arguments are: <code> register_post_type( 'Event', 'public' => true, 'rewrite' => array( 'slug' => 'eventy'), 'has_archive' => false, 'hierarchical' => false ) </code> It works fine in general. However if I try to rewrite the URLs in <code> function... | Step 1, add the rewrite tags for custom event year and month query vars, then register the event post type with those tags in the slug argument of the rewrite argument: <code> function wpa83531_register_event_post_type(){ add_rewrite_tag('%event_year%','(\d+)'); add_rewrite_tag('%event_month%','(.+)'); register_post_ty... | Custom post type 404s with rewriting even after resetting permalinks | wordpress |
I'm using CF7 and I need to have a dropdown with a non selectable category "header" such as US States AL AK AR...etc. Countries Afganistan Albania etc.... With "US States" and "Countries" not an option to submit. Thanks http://wordpress.org/extend/plugins/contact-form-7/[1] EDIT: I solved the problem myself if anyone h... | I can see how your solution works, but there is a semantic element created for exactly what you want: <code> <optgroup> </code> . Whatever your solution, I'd encourage you to use that instead. Searching for "contact form 7 optgroup" you'll discover that other people are looking for the same thing you are and tryi... | Contact Form 7 "non-selectable" options in a drop down | wordpress |
I got this code to show my thumbnails images and videos on my blog page, but when i try to use to show the thumbs in another page, it doesnt works. Function to display images and videos thumbs <code> function show_blog_posts() { global $post, $blog, $posts; $first_vid = ''; ob_start(); ob_end_clean(); $output = preg_ma... | You are passing <code> show_blog_posts </code> two parameters... <code> $str .= show_blog_posts($post->ID, ''); </code> ... but you have defined it to accept none... <code> function show_blog_posts() { </code> There seems to be some disconnect between your two blocks of code. I'd suggest actually passing the <code> ... | Shortcode Function not working | wordpress |
I have a custom page called owner-login that has a <code> wp_login_form() </code> How can I disable wp-login.php so that: when a user writes <code> wp-admin/ </code> it will redirect him to the owner-login (if not logged) when a user writes <code> wp-login.php </code> it will redirect him to the owner-login (logged/not... | Try something similar to this: <code> function is_login() { return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ); } function redirect_login() { if ( is_login() ) { wp_redirect('http://example.com/customloginpage'); } } add_action( 'init', 'redirect_login' ); </code> You'll need to modify t... | Redirect wp-login | wordpress |
I have a question regarding gform_pre_render ? I have dealer form. Which basically you choose your county, and then your dealer. Dropdown A = Dealer Country Dropdown B = Dealer Name I have about 15 countries, and I am using get_terms in the gform_pre_render function to list all my countries that I have assigned to a de... | Eventually the solution I used was this. Upon change of Dropdown A I have an ajax function request tha re-populated Downdown B with the filtered options based on the selection in Dropdown A. See the ajax jquery script... <code> countryFilter = function () { var countryClass = '.dealer-country select', dealerClass = '.d... | gravity forms : use previous dropdown choice as variable in gform_pre_render? | wordpress |
I want to have a picture or multiple pictures on each page in wordpress. AFAIK there are two standart ways of doing this in WYSIWYG editor, attach file etc widgets. Problem is, those wont do for my clients. So how can I make a custom field on each page, where the user selects a pic if he wants. I know there is a plugin... | It sounds like "Featured" or "Thumbnail" images would work. These are enabled by default for 'posts'. For 'pages' they need to be enabled, but that is as simple as adding <code> add_post_type_support( 'page', 'thumbnail' ); </code> to your theme's <code> functions.php </code> hooked on <code> init </code> , and, of cou... | Need custom picture field for pages | wordpress |
I have several WordPress running plugins on my site and as per suggestions of wordpress performance optimizations I am planning to do the optimizations on plugins myself. However, that will mean that I will have to modify existing plugins codes. Now, as WordPress plugins release frequent updates, the updates will wipe ... | Create a local repository in Git (or SVN) for the plugin, and each time an update happens: merge the changes into your adjusted version, test it in your local copy of the production site, then push your updated code to your site. But much better would it be to send your improvements to the plugin author, so she can use... | How to sync with plugins update after I have done manual optimizations? | wordpress |
I'm implementing an A-Z index for a custom post type. I've got my links printing out the page and the query working for the letters. However, the numbers are tripping me up because I don't want them to work quite the same. I want the first link to read '0-9' and clicking it to show all posts that start with a number. I... | The solution given by @RolandoMySQLDBA will give you all posts because you have a <code> * </code> and not a <code> + </code> . The <code> * </code> means to return zero or more matches, which is not what you want. In this case, you actually don't need either, but just to match the first character. Try this: <code> $sq... | Custom query to get post names beginning with a digit | wordpress |
I started a wordpress project for a client which has an e-commerce part. So I decided to try Woocommerce. Nevertheless I'm not yet familiar with this "big" plugin. The client has several specific needs and I'm not able to say if the plugin would cover those needs. This is an airsoft website. The users will be able to r... | I believe you are asking for product variations . | Dynamic price product | wordpress |
I'm developing a plugin that doesn't use a custom post type, but separate database tables. It's a plugin that displays a list of courses with links that lead to the different course detail pages, where the user then can subscribe for a course. In the current state, I'm using a shortcode to get the plugins data into a p... | I would use the <code> is_page_template() </code> conditional: <code> if ( is_page_template( 'page-courses.php' ) ) { // The current page uses your // custom page template; // do something } </code> Edit You would use this conditional inside your filter callback: <code> function wpse83525_filter_the_title( $title ) { i... | Change the_title() of a page dynamically | wordpress |
Is there a way I can return the shortcode text instead of the output. My code function is hooked into 'the_content' and I know if my function contain shortcode it will automatically generate the output. I just want to output shortcode text e.g [gallery] <code> add_filter( 'the_content', 'show_on_front', 10 ); function ... | Another way is to use a shortcode to display shortcodes :) <code> add_shortcode('SH','shortcode_display_handler'); function shortcode_display_handler($atts = array(),$content=null){ $content = str_replace("[","&#91;",$content); $content = str_replace("]","&#93;",$content); return $content; } </code> Usage: <cod... | Need to return shortcode text instead of the output | wordpress |
I modified my index.php to check if the search query is an author and if yes, display articles of that author. That is working fine but as soon as you go to page 2 of the results, wordpress triggers a 404 error. So I guess Wordpress is not calling the index.php on http://www.test.com/page/2/?s=my+search+query and I als... | <code> index.php </code> is the default template, the fallback. If we look here: http://codex.wordpress.org/Template_Hierarchy And at the diagram: We can see here that search.php is the appropriate template. Have you considered using author.php and the author archives instead of modifying the search template? There are... | Wordpress triggers 404 on page 2 for custom search query | wordpress |
Using Contact Form 7 Situation When a visitor fills out a form on the website, they enter: Name Email Phone Address (Street, City, State, Zip Code) Message I need to save this information to the database for future reference and I need to send an email to a central email address and to a specific email address, which c... | Thanks to Michael Simpson, from Contact Form DB. The solution is listed (kind of hidden) on the Contact Form DB website in the article - CF7 Menus with Pipes Add to functions.php <code> function myFilter($formData) { // Change $formData return $formData; // be sure to return it } add_filter('cfdb_form_data', 'myFilter'... | How to choose email recipient in Contact Form 7 based on address state input in form and save to database | wordpress |
I cannot get this query to work properly. It just renders one post even though I have three posts that are categories in the 'Firm News' and 'Test' categories. Can anyone see a problem with my code? <code> <?php $myquery = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'OR', array( 'taxon... | You aren't looping through the results. Here is your code: <code> $m = new WP_Query( $myquery ); if ( $m->have_posts() ) : $m->the_post();?> <ul><li <?php post_class();?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li></ul> <?php endif... | Tax_Query using WP_Query not working | wordpress |
I am trying to use <code> auth_redirect </code> to automatically redirected not logged-in visitors when then visit a specific page. Here is the code I use: <code> add_action('template_redirect','wpse16975_check_if_logged_in'); function wpse16975_check_if_logged_in(){ $pageid = 29; if(is_page($pageid)) auth_redirect(); ... | The problem is that this function is normally used in the backend. To use it in the frontend, you need to add the following filter: <code> add_filter( 'auth_redirect_scheme', 'wpse16975_check_loggedin' ); function wpse16975_check_loggedin(){ return 'logged_in'; } </code> Then <code> auth_redirect() </code> will work as... | Using `auth_redirect` : keeps asking me to login even when I'm logged in | wordpress |
I use custom metabox with date (day, month and year). The problem is when I try to transform date number to date word - for example 10 to be October. I use this code: <code> function eventposttype_get_the_month_abbr($month) { global $wp_locale; for ( $i = 1; $i < 13; $i = $i +1 ) { if ( $i == $month ) $monthabbr = $... | The code you are using is specifically for the month abbreviation, (Oct). You should be using this: <code> function eventposttype_get_the_month($month) { global $wp_locale; for ( $i = 1; $i < 13; $i = $i +1 ) { if ( $i == $month ) $month =$wp_locale->get_month( $i ) ; } return $monthabbr; } </code> | Metabox date month number to word | wordpress |
I've been messing around / searching for hours and still can't get this to work, so i'm finally giving in and asking for some help. I'm trying to write a custom walker that shows only the current pages children, or if there are no children display the pages siblings. For example, take the following menu tree: 1.0 1.2.0... | This is the walker I used to display only children of the current menu item. Or the menu items siblings if it doesn't have any children of its own. There are comments throughout the class explaining each section <code> <?php class SH_Child_Only_Walker extends Walker_Nav_Menu { private $ID; private $depth; private $c... | Custom Nav walker display current menu item children, or siblings on no children | wordpress |
I want display Microsoft Excel xlsx sheet in wordpress. How i can do that? Also it will be looking like excel sheet. http://i.stack.imgur.com/tBofs.png Thanks. | Your best bet will be using the Google Document Embedder plugin . It has sketchy support for the new X MS Office files, but will sometimes work. If not, you'll need to re-save the file as the old XLS filetype. | Put Microsoft Excel xlsx document | wordpress |
I'm currently using a version of this function - stackexchange-url ("post formats - how to switch meta boxes when changing format?") which hides all meta boxes until a corresponding post format is selected (Ie; If someone selects "Video" then my custom Video meta box shows up) But when the post is saved all the meta bo... | Try this one: <code> jQuery( document ).ready( function($) { // Starts by hiding the "Video Options" meta box $( "#video-options" ).addClass( "hidden" ); if( $( "input#post-format-video" ).is(':checked') ){ $( "#video-options" ).removeClass( "hidden" ); } // If "Video" post format is selected, show the "Video Options" ... | Hide meta box based on post format | wordpress |
I have been reading through Codex and other SO and SE posts regarding this. But I am confused. I used home_url() and site_url() to linking the site's home and it gave same results. As I was using qTranslate for bilingual implementation. And had its language switcher. Found later, when clicked on the home logo (used <co... | The difference in your case is in filters being applied to output of these functions. While bloginfo applies one of these filters: <code> if ( 'display' == $filter ) { if ( $url ) $output = apply_filters('bloginfo_url', $output, $show); else $output = apply_filters('bloginfo', $output, $show); } </code> Function home_u... | Difference between bloginfo('home') and home_url() and site_url() | wordpress |
I am trying to edit the price value for a single product. In single-product/price.php there is a template call to $product-> get_price_html. How can I edit that function/method to change the way the HTML is presented. At the moment even if I delete all the contents of the function located in <code> class-wc-product </c... | Core and plugin files should never be edited directly, as any updates could overwrite your changes. If you look in WooCommerce source at the <code> get_price_html </code> method, there are a number of filters available to modify the output of the function. See <code> add_filter </code> in Codex for more info on adding ... | How to edit the get_price_html on woocommerce | wordpress |
Can some one let me know how I can create custom Category and Post type including the items in side the red box (Please take a look at following image link) and add them to WordPress dashboard? There is an image a this link , sorry I wasn't allowed to attach image on the post Thanks | Let's go. First, create your custom post type (products): <code> add_action( 'init', 'add_post_type_products' ); function add_post_type_products() { $labels = array( 'menu_name' => _x('Products', 'your_text_domain'), // the menu name text. This string is the name to give menu items. Defaults to value of name 'name' ... | Custom Post Types on Custom Categories | wordpress |
I need to show a list of custom taxanomy terms assigned to the current post type with a name and a custom field. (Created with Advanced Custom Fields) Currently I use the following code, to show a list of the custom taxanomy terms assigned to the current post: <code> echo '<ul class="taxanomy-name">'; echo get_th... | Use the <code> get_the_terms </code> function instead so you can build the list manually and access the <code> term_id </code> for each term. <code> $terms = get_the_terms( $post->ID, 'taxanomy-name' ); echo '<ul>'; foreach( $terms as $term ): echo '<li>'; echo $term->name; the_field( 'custom-field-na... | Show custom field from custom taxanomy term on custom post type | wordpress |
I stackexchange-url ("found") this code for custom field add category editor. I added custom field to the Category. e.g. My field name is Hastag and i have a Sport category. And i want to call display Sport's custom field(I want to call current category custom field). How can i do this? CODE: <code> // the option name ... | I edit your code. And it worked right now. Thank you @s_ha_dum CODE: <code> if ( is_category() ) { $current_cat = get_query_var('cat'); } $tag_extra_fields = get_option(MY_CATEGORY_FIELDS); if (isset($tag_extra_fields[$current_cat])) { echo $tag_extra_fields[$current_cat]['my_title']; //i added this line. } </code> | How can i call from custom fields to the category editor? | wordpress |
I'm developing my own theme and added this in a function which is called with the hook <code> after_setup_theme </code> to support infinite scroll: <code> add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'footer' => false, 'wrapper' => false ) ); </code> I got this from http://jetpack.me/... | You need either a <code> content.php </code> or <code> content-<post format>.php </code> OR use a render: <code> add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'footer' => false, 'render' => 'render_function', 'wrapper' => false ) ); function render_function() { get_template_pa... | Infinite Scroll not working in own theme | wordpress |
I'm helping a friend with a WordPress blog since I'm a "computer person," although I have no specific WordPress experience and I haven't used PHP in years. So, I really appreciate any light that anyone can shed on this subject. The primary purpose of the blog is to catalog items and there are about 8,000 posts, each co... | All your issues could be solved with some MySQL queries. Regarding point #1: if you are using mod_rewrite then I recommend using absolute URLs for images in posts, if you are displaying full post content (including its images) on other pages - as you suggest. You can do a MySQL search/replace as follows: <code> UPDATE ... | Featured Images not appearing | wordpress |
I hope the following question is acceptable here, as it's half WordPress-related and half-business related. Updating WP regularly is important for security purposes, but it can be time consuming if there are many websites to update and even more if some updates require plugin updates (and in some cases, a plugin ceases... | I don't think there's a best solution, but whatever you decide to do, speak to the client about the issues, reach an agreement and put it in writing. I think it's important to discuss why we are using WordPress/theme frameworks/3rd party plugins, and what that means. The advantages: vastly reduced development time, a g... | Updating client websites on a regular basis | wordpress |
I'm developing my own theme on a website where I use the polldaddy polls & ratings plugin. I've set the ratings to show up on the homepage and that's working with e.g. the twentytwelve theme. However with my own theme, I do see the polldaddy div, but there's nothing in it: <code> <div class="pd-rating" id="pd_ra... | The <code> wp_footer() </code> function has to be called in <code> footer.php </code> , just before closing the page with <code> </body> </code> . | Polldaddy doesn't show up on own theme | wordpress |
I've installed wordpress MU, and established a different site in my domain/dev/sitename -- but I want to then install a theme on that site, and edit it directly. However, my FTP only shows the main Wordpress installation. How do I get at the /sitename subdirectory? | You don't need to get to the <code> /sitename </code> sub-directory. You install the theme in the <code> themes </code> sub-directory, and enable it for all sites. WPMU doesn't have an out-of-the-box capability to enable a theme for one site only, but I there might be plugins that give that functionality. | Accessing multiple sites via FTP | wordpress |
I've discovered a workaround to get wp_category_dropdown to display as a multiple select field. My code is as follows: <code> <?php $sponsors = wp_dropdown_categories( array( 'child_of' => 0, 'class' => 'postform', 'depth' => 0, 'echo' => 0, 'exclude' => '', 'hide_empty' => false, 'hide_if_empty' =... | The dot <code> . </code> in your code is evaluated as string litral, and not concatenation. Meaning if <code> $inpCnt </code> was equal to <code> 5 </code> for example, php will search for <code> name='scrape['.5.'][sponsors]' id= </code> and will fail to find it. You can either remove the dots while still using the do... | Trying to get variables in hacked category dropdown | wordpress |
I want to use the datepicker that gets bundled with WordPress on the front end of a website. I enqueued <code> jquery-ui-datepicker </code> but the datepicker isn't styled(no js error in console). Is there a corresponding <code> wp_enqueue_style </code> for that? I used this code in <code> functions.php </code> <code> ... | As far as I know, there is not style for datepicker. You have to register your own. The code then will be: <code> function rr_scripts() { wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) ); wp_register_style( 'bootstrap_css', get_template_directory_uri() . '/assets/css/bootstr... | Inbuilt style for jquery-ui-datepicker | wordpress |
I have one question. I use latest Wordpress and Budypress. I have language files for buddypress - .po and .mo. My question is where I need to put the files, how I need to rename them and is there any function that I need to add somewhere (for example functions.php) to load them. I checked this page and try to follow th... | The naming convention for plugins translation files ( <code> .mo </code> and <code> .po </code> files) is <code> pluginname-language_COUNTRY.mo </code> . So, for example, a French translation files of Buddypress will be: <code> buddypress-fr_FR.mo </code> and <code> buddypress-fr_FR.po </code> . After renaming these fi... | Buddypress Language Files Question | wordpress |
A lot of WP JS is minified and therefore it's hard to be analyzed in the Console. Is there any way to have all scripts uncompressed? | Yes there is, from Debugging in WordPress codex, you need to define <code> SCRIPT_DEBUG </code> in <code> wp-config.php </code> to force WP to load the <code> dev </code> versions of the scripts: <code> define('SCRIPT_DEBUG', true); </code> | Does WordPress Development Mode Exist (with not minified JS)? | wordpress |
Working on a project where I would like to have buttons within the actual visual editor area where the user can click on the placeholder image and it brings up the upload dialog. I've seen that people create their own buttons that adds boxes that the user then should select with their mouse and then click the add media... | such an answer would likely become unworkable/unusable after a WordPress update, as TinyMCE get updated and APIs change stackexchange-url (" - by @TomJNowell") While I agree with Tom, there still an be a general answer that explains the general concept and the parts that aren't moving. The PHP plugin to set the default... | Possible to create placeholder images in Wordpress editor that are clickable (should bring up uploader)? | wordpress |
With WP 3.5, they updated the image resizing scripts with <code> wp_get_image_editor </code> . Currently, in this standalone script that is accessed with Ajax, I have included <code> wp-load.php </code> so I can access all of the WP functions. Particularly, <code> $wpdb; </code> . In order to use the <code> $wpdb </cod... | Turns out I'm just silly. WP_Error was the undefined method, not resize. I was sending a bad image location through the resize function. How silly of me! It was working all along. I've included this on top <code> $parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] ); require_once( $parse_uri[0] . 'wp-load.p... | Using wp_get_image_editor in a standalone script | wordpress |
I'm creating a plugin for a friend to log search terms on his site. It's very basic. It creates a new table to store terms entered in the search box. It converts the search term to lower case, checks the database for a matching term and either inserts the term into the database or increases the count of a matching term... | I was able to recreate this, but it was a CDN (edge cache) and/or browser cache in my configuration that was bypassing your query. For the browser cache to be a problem, the searches had to occur as the result of a link click. For example, if you clicked a link to ?s=term, it would check the browser cache first. If thi... | Plugin Not Working, But Only On GoDaddy Hosted site | wordpress |
in this page google help us to enable our profile image on google search list when some one search get results from our blog post. my question not about how to do that ... like stackexchange-url ("this link that closed") ... but about the blog that has many authors that in the Google article i cant find anything about ... | Author info is two steps: Link pages on your site to the Author's Google+ Profile, the easiest way being a rel="author" <code> <link /> </code> tag in the <code> <head> </code> section. Authors link the the site on their Google+ profile, the "contributes to" section (or whatever that happens to be called. S... | how to connect the author profile with google webmaster tools in multiuser blog? | wordpress |
I have in the database a table with the <code> user_id </code> and corresponding <code> group_id </code> values, so each row contain the ID of the user that is a member of a group and the related group ID. The question is : How to display the names of users from a specific group, plus some metadata, with a shortcode, f... | Below is my own answer to the question. I will appreciate any constructive comment. <code> add_shortcode( 'group_members', 'group_members_shortcode_handler' ); function group_members_shortcode_handler ( $atts, $content = null ) { global $wpdb; $querystr = "SELECT * FROM wp_groups_user_group"; $users = $wpdb->get_res... | How to display the names of users from a specific group with a shortcode? | wordpress |
I have an author page, and I want to list posts from current author's categories. e.g. I'm viewing John's page, and John wrote in Sport, Tech, News, Computer categories. Then my code list from this (Sport, Tech, News, Computer) categories list random 10 post. But something is going wrong: Those 4 categories have 25 pos... | Granted, I may be misinterpreting you. Your post is not very clear but ... <code> category__and </code> will require the posts to be in both categories. It sounds like you need posts in any of the categories. You should be using <code> category__in </code> so that you get an <code> OR </code> match on the categories in... | How can i list random post from multiple category? | wordpress |
Is there a way to delete a custom field (in the sense of complete removal from WP database) without using a plugin? | If you have access to phpMyAdmin, these steps should do the trick: Step 1: Login to your hosting account and launch myPHPadmin from the cPanel, or equivalent, to access the WordPress database engine. Step 2: Enter a select SQL command to list all the meta keys you want to remove. In this example, I want to find and eve... | Deleting a custom field field | wordpress |
I have this issue where I need to get all page templates. I know there are ways to get them based on their name. I know that I can include a page template but I am trying to include them in the loop on the index page. I just installed the 2012 theme, modified the header to include my scripts. I used a function that Mil... | Checking for <code> get_page_templates() </code> in the core , I found a workaround that doesn't break the theme like: Fatal error: Call to undefined function get_page_templates() I'm using this just after <code> <body> </code> and works ok: <code> $templates = wp_get_theme()->get_page_templates(); foreach ( $... | get page templates | wordpress |
How can I add custom text editor in wordpress? Is there any way to do that? If not, How can I add or remove certain features from it? Thanks in advance. | You can use TinyMCE,CKeditor plugin. | How to add custom text editor in add post section? | wordpress |
I would need to know how much time is left between now and the next time a specifc Cron Job is done. For another answer I built a basic stackexchange-url ("cron inspector plugin which can be found here"). Reason I'm asking is that I'm already that wasted from working that I can't think straight at the moment. :/ Thanks... | Edit: <code> wp_next_scheduled() </code> returns the timestamp of the next scheduled job of a specified wp-cron job-arguments pair . Please note that this differs slightly in functionality to the answer below, in that you have to provide the arguments passed to cron job's callback (if it has any). The original answer w... | When does next Cron Job run (time from now)? | wordpress |
I got this function and i want to make the contents divs of "foreach" as return. How can i do that? <code> <?php $args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date"); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post);... | Build a string instead of directly outputting the contents. <code> $str = ''; foreach ($postslist as $post) : setup_postdata($post); $str .= '<div class="events">'; $str .= '<p><strong>'.get_the_date().'</strong></p>'; $str .= '<p><a href="'.get_permalink().'" title="'.esc_attr(ge... | Shortcode of a function | wordpress |
I want to do some actions according to image type and size, but the script I'm using is kind of heavy and is skyrocketing my wait time (first byte) from 5 to even 40 seconds (usually it's bellow a second). <code> $image_data = wp_get_attachment_image_src( get_post_thumbnail_id($post -> ID), 'full'); $animated = is_a... | That function looks like the kind of thing that would slow down a site. :) The first thing I'd recommend is that you not run that function on the front end. Run it when the image is uploaded and store the result in the database using <code> wp_update_attachment_metadata </code> . You can then retrieve the data with <co... | Actions according to image type and size | wordpress |
I hope the following question is acceptable here. I rely entirely on copy/paste for most WP functions, however I guess WP veterans don't. Is it important to know by heart the common WP syntax, and if it is, do people actually make an effort to memorize them just like we memorize a piece of poetry or a quote? | Not everyone will follow convention, so you can be assured if you are copy-pasting then you are getting a mix-and-match approach from people who do it "right" and do it "wrong" and sometimes the difference between right and wrong is a matter of opinion, lets not forget. Also this applies to NOT only Syntax Style but al... | Memorizing syntax | wordpress |
Sometimes I want to access one particular CPT to extract something from it, for example a custom field value: <code> $group = new WP_Query( array( 'post_type' => 'group', 'p' => $group_id ) ); while ( $group->have_posts() ) : $group->the_post(); $group_type = get_post_meta($post->ID, "group_type", $singl... | how about get_post ? <code> $post = get_post( $p ); $group_type = get_post_meta( $post->ID, 'group_type', true ); </code> | Avoiding using a loop to access a single post | wordpress |
I have a Featured Post Category. Im marked some post Featured. When i viewing a category page(e.g. Sport), i want to list on sidebar both marked post list (e.g Featured and Sport,) I tryed with that following code.It's worked for me but when i using my code i see two category post (e.g Sport ), category post list affec... | I think you're asking about your custom secondary loop affecting your main loop, correct? <code> query_posts() </code> alters the main loop. A quick fix would be to call <code> wp_reset_query() </code> after your custom loop to reset the query data: <code> <?php wp_reset_query(); ?> </code> However, it's more eff... | How can i listing current category and Featured Category post list? | wordpress |
In 3.4 I used the following function to change image upload folder by post type. stackexchange-url ("Different upload directory based on post type in a theme") Now it doesn't work anymore in 3.5. Do you have any idea how to replace this function in 3.5 version? thanks | Yes, it does. I had to do something similar just yesterday and worked out this solution. About the same as the linked solution, but with a bit more error checking. <code> <?php add_filter('upload_dir', 'cgg_upload_dir'); function cgg_upload_dir($dir) { // xxx Lots of $_REQUEST usage in here, not a great idea. // Are... | Post type specific upload folder in 3.5 | wordpress |
Some way to Flush or Overwrite all Imported Content in a Site for a Fresh Import - How? Is there an easy quick way to do this? To delete all Pages, Posts, Comments and stuff that got imported? Or some way to force a FLUSH of the information when I import a new .XML? I've imported a bunch of wrong content into several s... | This may be what you're looking for http://wordpress.org/extend/plugins/suicide/ . As a super admin you can select which sites you would like to remove the content from within your multisite setup. | Some way to Flush or Overwrite all Imported Content in a Site for a Fresh Import - How? | wordpress |
I thought there was a conditional for a custom image header that could check whether an image had been added (not whether the feature was enabled, but actually being used). I wanted to use it to add a body class, but I can't find it again. Does anyone know of how to check if the site has a custom header? | you could try the following right before you call the <code> body_class() </code> function: <code> <?php $header_image = get_header_image(); if( !empty( $header_image) ){ $custom_body_class = 'has-header-image'; } else { $custom_body_class = 'no-header-image'; } ?> <body <?php body_class($custom_body_class)... | Conditional Custom Image Header | wordpress |
I have created a group with the Groups plugin and I want to display the members list of that group. I put the shortcode <code> [groups_group_info group="Group Name Here" show="users"] </code> in a page, but it displays only the usernames of members, like this: username1 username2 ... usernameX I want to display their n... | Bellow is the adapted function (by 24 rows shorter than the original), as was suggested by the commenters (many thanks!). It will work only if the Groups plugin was installed and activated. <code> add_shortcode( 'groups_group_info', 'groups_group_info' ); function groups_group_info( $atts, $content = null ) { global $w... | Convert usernames listed by the Groups plugin shortcode to displayed names? | wordpress |
Im building a cinema site, In post's i store the Movies I have a post_type name "box-office" , this post type have 1-10 custom fields, with i can select the movies stored in post's. locul_1 - is one of that. How can i display on front page the movie atached to that custom field I want to display on front page 5 movies ... | Here's the code from the ACF Relationship Field example adapted to your field name. I edited out some of the markup just to simplify things. A couple of notes: Use a proper text editor and indent your code so it is readable. A soup of random indentation makes it much more difficult to debug code. The ACF Relationship F... | How can i display on front page a movie that is atached in a post type | wordpress |
I'm currently developing my WordPress locally, committing my code to GitHub with Git and then SSHing into my server and doing a "git pull" to update my code. Is this a good option for code deployment onto a WordPress site (I obviously have root level access to my server in this case.) I know of things like Capistrano, ... | I use git for this and find it works really well. A few suggestions: Add your uploads directory (wp-content/uploads) directory to your <code> .gitignore </code> file. Run a web server and database server on your development system so you can test changes locally before pushing them to production. Keep your database con... | Is Git/GitHub a good WordPress deployment solution? | wordpress |
I want to remove the website url from all <code> the_post_thumbnail() </code> so they become relative and remove/add attributes from the output. So far I got the following code added to functions.php of the theme, xcept I am not sure how to modify the thumbnail <code> $html </code> for the second part. Help is apprecia... | This is a pretty wonky function but it does the job, it will turn your post thumbnail into a relative url. Not sure why you would do this, use at your own caution, probably want to add some error checking. <code> function wpse_83137_relative( $html, $post_id) { // get thumb src $post_id = ( null === $post_id ) ? get_th... | Post thumbnail relative link and HTML modify | wordpress |
In my design I need use this kind of wordpress custom menu. Menu (I am able to do this) Menu element with sub menu. (but not this one) In this UI , I can not able to separate sub-menu to the new line with CSS. Then how can I add specific menu sub menu to new line. | I think, your question is similar to mine. I tried a similar thing earlier. Can check stackexchange-url ("this StackOverflow thread") started and answered by me. | How to create this kind of sub-menu in new line? | wordpress |
To change the upload directory I have to do this: <code> define ( "upload", "<new upload location>" ); </code> How can you change the themes location? I like to create a folder themes in the root directory. | You can register additional directory or directories with themes by using <code> register_theme_directory() </code> function, that accepts filesystem path to folder. Note that this isn't typical and even while core handles it mostly fine, third party code in themes and plugins might not. | How do you change the theme location? | wordpress |
Im listing current category of all author list but I want to list random author list from current category. I was try 'order' => 'RAND', RAND code its not worked. My Code: <code> function getCurrentCatID(){ global $wp_query; if(is_category() || is_single()){ $cat_ID = get_query_var('cat'); } return $cat_ID; } $current_... | The Codex lists <code> rand </code> as the <code> orderby </code> string , not <code> RAND </code> . I suspect that either works but I haven't checked. But that isn't how I'd do this. I'd lean toward something like... <code> $current_category_ID = getCurrentCatID(); $current_cat_id = $current_category_ID; $author_array... | How can i list random author? | wordpress |
I have a template part like this: <code> <nav id="subpagemenu" class="sidebar"> <?php get_template_part( 'nav', 'subset' ); ?> <?php get_sidebar(); ?> </nav> </code> Both of these are conditional, I mean, nothing will load if there's no content. if there is content, they both load boxes like: <c... | You can define a global variable in your theme functions.php <code> global $mywidgets; $mywidgets = false; </code> in your template part add <code> global $mywidgets; $mywidgets = true; </code> and in your functions you can check if its set to true: <code> function my_function(){ global $mywidgets; $mywidgets = true; i... | Checking whether template part is loaded in a page | wordpress |
I'm using jigoshop as main ecommerce plugin. Jigoshop use Taxonomies call, product_cat and product_tag. In my theme I use a default (h5bp) 404.php, so every time a tag doesn't exist I get the default 404. But I need to have a special template that give a <code> THIS TAG DO NOT EXIST </code> how can I do this? I'm using... | If you want to use an entirely different template, you could filter <code> 404_template </code> and check query vars for a specific taxonomy: <code> function wpa83050_404_template( $template = '' ){ global $wp_query; if( isset( $wp_query->query_vars['product_cat'] ) ) $template = locate_template( array( "product_tax... | Taxonomy Tag Conditionals | wordpress |
I have the following issue: Two Custom Post Types, lets call them cpt1 and cpt2 . In cpt2 , I have a custom meta box in which you can select a post from cpt1 , its <code> post ID </code> is stored in a meta value called <code> postid </code> . The permalink structure of cpt2 is <code> /%post_type%/%post_name%/ </code> ... | I changed this line: <code> $wp_rewrite->add_rewrite_tag( '%selected_meta%', '([^&]+)', '?meta=' ); </code> Into: <code> $wp_rewrite->add_rewrite_tag( '%selected_meta%', '([^&]+)', 'post_type=ervaring&meta=' ); </code> Wich was for both issue 1 and 2 enough to work with. | Permalink structure by Post Meta value | wordpress |
We're using multisite and pages/posts will not paste from word using the paste from word tool. I've tried everything imaginable, disabled theme (no plugins or network plugins enabled) We've tried paste in the editor, paste within plain test, paste within paste from word. We've created a new site (which works) then copi... | Problem was the page encoding. The wordpress database is UTF-8, i had switched the default to ISO-[something] to match the database we're using to populate additional content and had not noticed any issue for over a month- until we started populating the blogs section of this page. We discovered the problem by followin... | WordPress MultiSite Paste from Word Tool Does not work | wordpress |
What I would like to do is to create a WP loop that will display info from a child page of an adult page ID, so the Page ID is 2. I would like to pick a page ID to display what page. So that way I could display information from another child page on an alternative page. Owen | This is a near duplicate of a number of questions here, but the "single random result" might make it somewhat distinct. <code> $args = array( 'post_type' => 'page', 'post_parent' => $post->ID, 'orderby' => 'rand', 'posts_per_page' => 1, 'no_found_rows' => true ); $child = new WP_Query($args); var_dump... | Displaying child page content of a certain parent | wordpress |
I created multiple post formats, and when i use an audio post format, i want to include some additional javascript for the audio player. So, i include the content-audio.php like this: <code> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'blog/content', get_post_format() ); ?> <?p... | As of WordPress 3.4, calls to <code> wp_enqueue_script() </code> can be made inline. So, it is perfectly acceptable to call it where needed, such as inside a shortcode callback, or conditionally based upon returned queries, as you've done here. | Is it safe/recommended to use wp_enqueue_script function outside the functions.php file? | wordpress |
I have a custom post type with a custom URL structure so it works like: <code> http://domain.com/custom-post-type/post1 http://domain.com/custom-post-type/post2 http://domain.com/custom-post-type/post3 etc. </code> Now I have multiple authors of these posts, so I want to enable an "Author Archive" for only these custom... | Change <code> custom-post-type </code> in the following to the name of your CPT, both the slug and <code> post_type= </code> in the query vars. Visit your Permalinks Settings page to flush rewrite rules. You could also put this in a plugin and flush rules on plugin activation. <code> function wpa83047_author_rewrite_ru... | Make Author Archive Page URL be a Subdirectory of a Custom Post Type URL | wordpress |
I' like to run a cron every 24 hours at midnight PST ( = GMT -8 ) This is what I have <code> if ( !wp_next_scheduled( 'cron_hook' ) ) { //reset on 00:00 PST ( GMT -8 ) == GMT +16 $timeoffset = strtotime('midnight')+((24-8)*HOUR_IN_SECONDS); if($timeoffset < time()) $timeoffset+(24*HOUR_IN_SECONDS); wp_schedule_event... | Almost, WP Cron jobs do not run at specific times, they are approximate, and all timestamps should be UTC, as WordPress always deals in UTC timestamps. If you want midnight PST, you'll want to specify 8PM UTC. Also for example, your above code suggests midnight PST, but it may not run at midnight PST. If nobody visits ... | Trigger a cron every 24h GMT -8 | wordpress |
Bellow is how I currently add, save and display an extra user meta field: <code> /* Add Extra Fields to the User Profile */ function extra_user_profile_fields( $user ) { ?> <table class="form-table"> <tr> <th><label for="publications"><?php _e("Publications"); ?></label></th>... | you could also use a label parameter in your shortcode, like this: <code> [user_meta user_id="1" label="publications"] </code> with these code changes: <code> * Display the selected user meta data with a shortcode */ add_shortcode('user_meta', 'user_meta_shortcode_handler'); /* usage: [user_meta user_id="1" label="publ... | How to save a label for an extra user meta field and to display it later? | wordpress |
I'm getting an "file.png exceeds the maximum upload size for this site" error. It's saying the upload limit is 1MB when trying to upload an image that is 2.5M on WP 3.5. It is setup in multi-blog mode (if that matters). I have set my php.ini file to 64M for post_max_size and upload_max_size, and it's working for other ... | It is setup in multi-blog mode (if that matters) That will matter a lot. you probably need to ask the super admin to change the upload setting for your site https://codex.wordpress.org/Network_Admin_Settings_Screen#Upload_Settings | Image Upload "exceeds the maximum upload size for this site", but php.ini is correct | wordpress |
This might be a dumb question - I'm sorry for that but: If I decide to alter "Reading Settings" and choose a front page for home I can define a "Static Page" and a "Posts Page". "Static Page" ain't leaving a question to me since it's what's gonna be grabbed if I click on my Logo. But where will I face this so called "P... | http://codex.wordpress.org/Settings_Reading_Screen "Posts page - Select in the drop-down box the name of the Page that will now contain your Posts. If you do not select a Page here, your Posts will only be accessible via other navigation features such as category, calendar, or archive links. Even if the selected Page i... | How to access the so called "Posts page" | wordpress |
I am working on a one page WordPress site. It's the first time I have tried this. I am on the fifth version with various degrees of success. I am starting a new version and I deleted everything in the theme folder except the header.php index.php, functions.php, footer.php, page templates and styles.css When I look in m... | Only the <code> page </code> post type can have a template assigned (of the default post types), it's the custom template you set in the Page Attributes meta box. If you have a <code> page.php </code> template file, your <code> index.php </code> will only be used to display <code> post </code> post types, so those post... | get all page templates | wordpress |
I am using WP 3.5.1 and lightbox plus 2.5.5 I have my lightbox set to "Use for WP Gallery" Lightbox is working successfully on one of my posts with a single image, but on another post I have 3 images and they are set to "media file" but when I go to the post, they are navigating to the attachment page instead, thus lig... | I have the Same issue, its a bug in 3.5.1 You have to select "Attachement page" from the dropdown menu, then go back to "Media file".. This will add gallery link="file" ids= to your script (which is missing) | Gallery set to "Media file", showing as attachment page | wordpress |
I would like to write a custom plugin that adds a custom panel below the post compose panel that will have a few fields and a submit button. JS will kick-in to submit content to the database, without saving or interfering with the post save/submit mechanism. The purpose is to save data to be used and quickly access whi... | In the WordPress World it is called "Meta box" and in your case it would be the same as for posts the only thing you would need to do different is the save function that should save the data in the options table , here is a modified example from the codex that should work for you as a starting point: <code> <?php /*... | How to Create a Custom Panel and Fields in Post Page [Plugin] | wordpress |
Is there any way to prevent double execution of do_action statements? For example, I have the following lines: <code> do_action('myhook1', 'myfunction1'); do_action('myhook2', 'myfunction2'); do_action('myhook3', 'myfunction3'); </code> There are also other plugins that "might" be executing them. Is there a built-in Wo... | To check if someone already hooked into <code> myhook1 </code> <code> if( 0 >= did_action( 'myhook1' ) ) do_action( 'myhook1', 'myfunction1' ); </code> If you want to check if the function <code> myfunction1 </code> was already called (maybe by a simple function call), you have to set a 'marker' <code> function myfu... | How to prevent double execution of do_action statements | wordpress |
I need to edit my comments.php to make emails NOT required. I've attached my code below, I understand that I need to get rid of $req and $aria_req from my email field, but as the site is live I don't want to try and make any changes without doing it properly. Thank you! <code> $author_name = get_comment_author(); $args... | You cannot change the requirement in a theme, just the presentation of that requirement. Make the settings in <code> wp-admin/options-discussion.php </code> instead: | Make email not required comments.php | wordpress |
Hi guys :) I know there is the <code> wpmu_new_blog </code> action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action when a WPMU blog is deleted? Something which looks like this: <code> add_action('blog_deletion_hook', 'f... | Yes, inside <code> /wp-admin/includes/ms.php </code> there is the action hook <code> delete_blog </code> . This test prevents a blog deletion: <code> add_action( 'delete_blog', 'prevent_blog_delete_wpse_82961', 10, 2 ); /** * @param int $blog_id Blog ID * @param bool $drop True if blog's table should be dropped. Defaul... | Perform action on WPMU blog deletion | wordpress |
I have a checked a few links but nothing seems to for me in getting the attribute value of a shortcode so that I can use it in a condition. <code> function bf_shortcode_slideshow($atts) { extract(shortcode_atts(array( 'location' => '' ), $atts)); ob_start(); if ( $location = 'home' ) { classslider = 'homeslider'; } ... | <code> include </code> changes the scope. You would need to declare <code> $classslider </code> global before defining it, and then use <code> global $classslider; </code> before using it. <code> function bf_shortcode_slideshow($atts) { global $classslider; extract(shortcode_atts(array( ... </code> I think that will fi... | getting values from a shortcode with an include | wordpress |
How can i count images form NextGen Gallery, the NextGen Gallery is insite a custom field. Custom field for NextGen Gallery is " poze " I search for it, i found this stackexchange-url ("NextGen - Display Image Count Per Gallery") <code> <?php global $wpdb; $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $w... | Assuming you actually have something in the $gallery object (hint: confirm that by <code> print_r($gallery) </code> in your template), then your code should work. Perhaps step back and leave the database stuff to NextGEN, just count the image IDs: <code> global $nggdb; $poze = get_field('poze'); if ($poze && co... | How can i count the images that are atacht to NextGEN Gallery | wordpress |
I'm trying to remove the export.php page from WordPress admin menu -> tools for a multisite so only the network admin could see it I have the following code so far but can't get it to work. <code> //*************************************************** // Remove export Page //*********************************************... | Whenever in doubt about a WordPress function, consult the Codex: Function_Reference/remove_menu_page . The correct function is <code> remove_submenu_page </code> hooked into <code> admin_menu </code> . <code> add_action( 'admin_menu', 'remove_submenu_wpse_82873' ); function remove_submenu_wpse_82873() { global $current... | How Can I remove or hide the export page in WordPress menu? | wordpress |
For image galleries, I need a code that uses next/previous links to bring you to the next/previous image in that post and keeps the images in the correct order you chose while inserting them into the post . (Every major news site seems to have this feature.) Currently, if you add <code> <?php next_image_link( false,... | These functions will help: <code> //function to get next or previous keys in an array function array_navigate($array, $key){ $keys = array_keys($array); $index = array_flip($keys); $return = array(); $return['prev'] = (isset($keys[$index[$key]-1])) ? $keys[$index[$key]-1] : end($keys); $return['next'] = (isset($keys[$i... | Gallery Inside One Post | wordpress |
I'm writing a plugin with an ajax request and I'm getting a weird problem. It works fine the first few times but then all of a sudden, the data ends up empty or NULL. This is the code: <code> /* in functions.php */ add_action( 'wp_ajax_rs-MYajaxAction', 'wpw_display_js_vars'); add_action( 'wp_ajax_nopriv_rs-MYajaxActio... | This stackoverflow answer has a good example of basic ajax posting. stackexchange-url ("stackexchange-url I would try adjusting your code so that the info you want to post is in the <code> data </code> parameter. jQuery isn't my strongest suit, but I was under the impression that the $_POST data came through that param... | Ajax object comes back empty | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.