Tag Info

New answers tagged

1

If you want to display a single custom field (post meta) then you can use: get_post_meta(); It has three arguments. The ID of the post The name of the post meta field (country_flag) Whether or not the value returned is a single string (in your case it will be); So the usage might be something like this: $country_flag = get_post_meta( $post->ID, ...


0

Supposing that each food item is treated as a post (perhaps even a custom post type), and the parameters (name/calories/etc.) are attributes of this post, you would do well to treat them as post meta fields. Various means exist to grant end-users the ability to maintain custom fields; my preferred option is Developer's Custom Fields, but other solutions ...


0

Here is a better solution: add_filter("user_register", "get_unique"); function get_unique($user_id){ $prefix = "PAY-"; do { $unique = mt_rand(); $unique = substr($unique, 0, 3); $unique = $prefix . $unique; } while (!check_unique($unique)); return update_usermeta( $user_id, 'memnumber', $unique );//$unique; } function ...


0

Then why don't you separate styles for both. So you can add styling for both differently. Like this. These are the styles for post/page title on inside pages #primaryContent h1 { margin: 10px 0 0; padding: 0; } #primaryContent h1.postTitle { font-size: 23px; margin: 0 0 20px; padding:10px 0; text-align:left; color: #b78a3c; ...


2

Here's a great codex article on the topic of creating administration theme: http://codex.wordpress.org/Creating_Admin_Themes And back to your question, you will want to load different stylesheets for different user roles, so you have to check who the current user is. Pay attention, the check is done using current_user_can() function and checking for ...


9

When you visit a fronted page WordPress will query database, and if your pages does not exists in database, that query is not needed and is just a waste of resource. Luckily WordPress offers a way to handle frontend requests in a custom way. That is done thanks to the 'do_parse_request' filter. Returing false on that hook you will be able to stop ...


0

I once used a solution described here: http://scott.sherrillmix.com/blog/blogger/creating-a-better-fake-post-with-a-wordpress-plugin/ Actually, when I was using it, I extend the solution in a way I can register more than one page a time (the rest of a code is +/- similar to the solution I'm linking from a paragraph above). The solution requires you to have ...


0

Add this in your functions.php function my_reg_page( $register_url ) { return home_url() . '/register/'; } add_filter( 'register_url', 'my_reg_page' ); This example would return a registration URL http://Yourdomain.com/register/ for the wp_registration_url() function


2

There are many choices here, and it is all up to you what you want to achieve and how you want to achieve it. My idea would be to use the templates available to avoid a lot of if else conditional statement. The Template Hiearchy makes provision for templates for terms, taxonomy-{$taxonomy}-{$term}.php, so you could create a tempate for each term. So for ...


0

FIRST BACKUP!!!!! NEXT, BE SURE THE BACKUP IS RIGHT Now, you can use this code in PHPMyAdmin UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'preview', 'edit') WHERE meta_key = 'dp_video_code' Make sure that's the correct name of the custom field, you can check it in the wp_postmeta table.


0

You should not use echo in this case. Please visit the function reference of get_template_part. As you will see, there is nothing to print: get_template_part doesn't return a value and doesn't warn if it fails to find a matching template file. Additionally, I recommend that you check out this question: Should we use get_template_part() in functions ...


0

<?php $currentlang = get_bloginfo('language'); if($currentlang=="en-US") $link_text = 'All Products'; else $link_text = 'Dummy Text'; ?> $return_string .= '<li class="wpc-category ' . $class . '"><a href="'. get_option('catalogue_page_url') .'">' . $link_text . '</a></li>';


0

To fix the empty input search issue you can substitute the function code with this: function template_chooser($template) { global $wp_query; $post_type = get_query_var('post_type'); if( isset($_GET['s']) && $post_type == 'products' ) { return locate_template('archive-search.php'); // redirect to archive-search.php } ...


0

Add a new input to the form, the name is key, you can easily access query vars that match a paremeter supporter by WP_Query using the function get_query_var. For example, you could try to generate an URL like this: http://example.com/?s=test&tag=5-personas,4-personas And with get_query_var(tag), you get the values, and the you create a custom ...


0

Figured out the answer! It turns out that in ACF, if you're using radio buttons and have key set for each value, the keys CAN in fact contain spaces! By matching the keys to the values (case-insensitive) I was able to get the conferences to display on the single-team posts.


3

I suspect what you're trying to do is implement related posts, and you're using post meta to indicate which posts are related to the current post. So if I have a handbag, and there are 5 related products, the handbag product has post meta containing the IDs of those 5 products. While this sort of works, it doesn't scale, and it isn't performant. Instead ...


0

To get them in the bar you could ignore the beautiful WP playlist ones and add your own using mediaelement.js directly, similar to this question. You basically extend MediaElementPlayer by writing buildXXX functions, and then specify them in the settings features property as an array (along with all the other controls). The following integrates them into ...


0

You can modify your menu by using walker. include('subMenu.php'); $menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu)); create a file subMenu.php in theme folder add below code. <?php class subMenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) ...


0

in style.css, enter something like this: div.wp-playlist-prev{ width:20px; height:20px; background-image: url("./theme_images_folder/something_icon.png"); } same for the next button.


0

Turns out $wp_customize->get_section( 'sidebar-widgets-footer_widgets' ) was returning an Array, although a quick print_r() makes it seem as though it was an Object. Anyhow. Simple fix: cast it to an object. $footer_widgets_section = (object) $wp_customize->get_section( 'sidebar-widgets-footer_widgets' ); $footer_widgets_section->panel = '';


0

I have done a complete answer on this a while ago on SO. You can see the complete post here. For the sake of WPSE users, I have copied my answer from that post. I have not edited it, this post was originally about adding and displaying a nav menu to the footer, but the same exact method applies for a header nav menu. I hope you find this helpful ORIGINAL ...


0

Same pages as answer above "5 and 9" can also be hidden/removed from backend with PHP: function hidepages_php( $query ) { if( !is_admin() ) return $query; global $pagenow; if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) ) ...


0

Instead of specifying the menus you want to remove, specify the menues you want to keep :) add_action('admin_init', 'nwcm_admin_init'); function nwcm_admin_init() { // Remove unnecessary menus $menus_to_stay = array( // Client manager 'nwcm', // Dashboard 'index.php', // Users 'users.php' ); ...


1

I always find this tutorial to be a good reference point to make a completely bespoke login form: http://digwp.com/2010/12/login-register-password-code/ It's not a complete and concise answer to your question but hopefully it will get you going in the right direction


3

As @Tomas Cot says, this page has everything you're looking for: https://codex.wordpress.org/Customizing_the_Login_Form Specifically, this section is what you're looking for: Make a Custom Login Page So far you've seen how to customize WordPress' built-in login page. You can also create your own custom login Page by using the wp_login_form ...


1

You need to use get_field function here instead of the_field. function wrapImagesInDiv($content) { if ( in_category( 'projects' ) ) { $pattern = '/(<img[^>]*class=\"([^>]*?)\"[^>]*>)/i'; $replacement = ' <div class="owl-wrapper"> <div class="owl-item $2"> ...


2

You can use htaccess to disable public access. in your .htaccess file add this. AuthName "Secure Area" AuthType Basic AuthUserFile /path/to/htpasswd/file/.htpasswd AuthGroupFile /dev/null require valid-user don't forget to change htpasswd address in this. You can create .htpasswd from here. http://www.htaccesstools.com/htpasswd-generator/ ...


0

thats easy. I use a Pluing for this "Private Only" Go to add new plugins section and search for it. or visit its plugin site Private Only Have fun & good luck with your blog Note: I have no affiliation with this plugin :-)


0

Finally, I had to add the required code inside another shorcode I had in place to create the content structure. That way I avoided creating an extra shorcode and was able to put the custom code in the exact position I wanted. Thanks to all those who helped.


1

The WordPress built-in editor supports two editing modes, "Visual" and "Text." The "Text" mode allows you to directly edit the actual HTML of the page (or post), including any <div> elements that might be there.


1

The code you need will vary slightly depending on whether the Conference field is storing a text string (like "Big Ten") vs. the ID of the Conference post. I'll include both: Text String Example // place this code inside the loop of your single-team template $conference_name = get_post_meta( get_the_id(), 'conference', true ); $conference = ...


0

The best way to create dynamic data outputs really depends on the what, why, and how. For example, if you're creating a theme that creates its own custom post type, say, to store information about the head honchos that run the business behind the site, then just create a "single-$CPTNAME.php" template that has the code that you want. Another method of ...


0

Assuming you are looking for a solution to conditionally display your custom fields on public facing pages (non-edit page), you can use WordPress Conditional Tags. if ( is_page_template('template-name.php') ) { // Execute Your Code }



Top 50 recent answers are included