Tag Info

New answers tagged

0

I found another way to do this: .headerNavMenu { width: 100%; display: table; text-align: center; margin: 0; } .headerNavMenu ul { display: table-row; } .headerNavMenu li { display: table-cell; margin: 0; }


0

Try this.. This is a pretty basic code and you might need to modify it to get it fully work, but it will get you started. function load_testimonials( $atts ) { extract( shortcode_atts( array( 'id' => '', ), $atts ) ); $out = '<div id="testimonials" class="flexslider">'; $out .= '<ul ...


0

Create a Page_YourCustomName.php . copy page.php content to your new file. add the following code to first Line : <?php /* Template Name: Your Custom Name */ ?> Once you upload the file to your theme’s folder , go to the Page > Edit screen in your admin dashboard. On the right hand side under attributes you’ll see template. This is where users are ...


0

Here's an alternate approach of filtering the posts after the query using whether the wp_get_attachment_thumb_url() returns an empty string to determine if the post has a thumbnail (featured image). //get all the posts however your query does it. simple example when there aren't a lot: $args = array("nopaging" => true); $posts = (new ...


1

Textdomain Error The error message mean, that you haven't a textdomain. There is required for translation of this string. In the first error message is the problem the missing textdomain on the function _n_noop(). Right usage as example below. _n_noop( 'Security Release', 'Security Releases', 'your_textdomain' ); Text Domain Information about the ...


0

I don't know how to do it with Pages, but with Posts or CPT I use the following list of of args : <?php $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'votes_count', 'orderby' => 'meta_value_num'; $wp_query = new WP_Query( $args ); ...


0

Now I'm developing themes for wordpress and I noticed how bad it is in front of anchor when we're talking about themes development. I could bring you plenty of examples to prove what I'm saying. Let's start with the "comment form" function: why the developer who's creating a theme must be forced to use the wordpress markup? You aren't, WordPress ...


2

max_input_vars is the limit on the total number of GET, POST, and COOKIE vars. To determine how many there are you can just count them. Here's a quick example in a WordPress context: function wpd_admin_error_notice() { echo 'This request contained ' . count( $_POST ) . ' POST vars, ' . count( $_GET ) . ' GET vars, and ' . count( $_COOKIE ) . ' ...


2

With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks. /** * Remove customizer options. * * @since 1.0.0 * @param object $wp_customize */ function ja_remove_customizer_options( $wp_customize ) { //$wp_customize->remove_section( 'static_front_page' ); ...


2

Let us look at the relevant line. I am reformatting it to easier understand what is going on: printf( _n('1 comment', '%1$s comments', get_comments_number() ), number_format_i18n( get_comments_number() ), 'text-domain' ); So what you are doing is calling printf with three parameters, each one now being on a separate line now as I formatted it. ...


1

I would not try to get too tricky and hide pages from users. What happens if they try to create a page with the same slug? I think it would just create confusion and more problems than it would solve. When you create the pages, store their IDs, not slug. Let users then change those through your options screen. This is similar to how WordPress tracks your ...


0

You could create a custom post type of "Static Pages" that do not allow you to update the titles. remove_meta_box( 'post_title' , 'your_custom_post_type', 'normal' ); remove_meta_box( 'slugdiv' , 'your_custom_post_type', 'normal' ); Then add in your static pages programmatically with wp_insert_post(); and force the slug and post_title to what you want. ...


1

CODE UPDATED WITH = ADD UNLIMITED SIDEBARS (JavaScript) Create a function that register sidebars, using [register_sidebar][1], starting from an option: add_action('widgets_init', 'my_custom_sidebars'); function my_custom_sidebars() { $sidebars = get_option('my_theme_sidebars'); // get all the sidebars names if ( ! empty($sidebars) ) { // add a ...


0

Follow the following steps to achieve your result, Use get_terms to fetch all of your parent taxonomies and render a drop-down with the title and setting a data attribute with the term ID. Please set the args "parent" to 0 and taxonomy to your taxonomy slug. Write a jQuery script to fire an AJAX on the above created drop-down. The AJAX should send the ...


0

Yes, you can include a check for is_home() or is_front_page() and return a different title based on that. Update: TwentyEleven does it like this for example (lines 27 to 45).


1

You can try the Theme Test Drive plugin to help you preview a development copy of your theme while a live site is still fully functional. Assuming it's the same theme you are working on (as it sounds like it) - you can copy the existing theme to a new theme folder, and just change the Theme Name value in the style.css in the development copy... then ...


1

WordPress default importer will not work for WooCommerce product attributes. There is a plugin available to import WooCommerce products which handles import for products as well as their attributes. I'll not paste the plugin URL here since it's a third party plugin, but if you google for 'WooCommerce import', you will easily get that plugin.


0

I appreciate your comments, I have looked into a possible repeated question, however I did not find it as helpful as the last comment by @michel after looking into the functions.php file I found this filter add_filter( 'wp_title', 'burger_wp_title', 10, 2 ); function burger_excerpt_length( $length ) { return 50; } Which I have gotten rid of and now I ...


5

Back with WordPress 3.4.1 the function next_post_link() did not have - see source - the $taxonomy parameter, so it won't work, no matter what. IIRC the parameter is available since WP 3.8 or 3.9 - but those are pretty old too. Just to say that very clearly, do NOT use such a old version(s) of WP.


5

Yes it is. It might get a bit clearer if you re-format this line $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); to: $title .= " $sep "; $title .= sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); The first parameter of sprintf expects a format which is here the return value of the __ function. The second ...


2

The answer to which framework you should use is — no one knows. From code perspective there is certain degree of baseline theme functionality/experience — enforced by formal standards. Those things are recommended/required for inclusion into official theme directory, outside of that people can do things a little more lax. Frameworks exist for different ...


0

If you need to change the permalink structure, it can be done in admin panel. Go setting -> permalinks and chose what you need in general settings


2

Before we go into details, it should be noted that the guides you are referring to is only what it is, a guide. Just like coding standards (which not even the core developers stick to :-)), the Wordpress Handbook is just a guide to developers, it is not the alpha and omega. The basic idea is to use this guide and implement these guideline in such a manner ...


-1

I was able to make it working by dropping the $excluded_terms = '' next_post_link( '%link', __( 'Next', 'twentyeleven' ), true, '', 'years' ); next_post_link( '%link', __( 'Next', 'twentyeleven' ), true, 'years' );


0

Figured it out using str_replace. First the location of the background image is stored in a string: <?php $backimg = get_background_image(); ?> Then perform a string and replace where the .jpg is removed at the end of the $backimg and is stored as $bgraw <?php $bgraw = str_replace('.jpg','',$backimg);?> It output as: ...


0

Finally, I found how to change the non-frame $button_labels of a WP_Customize_Image_Control by extending its class, not reassigning a new $type and implement an enqueue() function to enqueue a pure JavaScript code to manipulate the non-frame labels, like this to change the dynamic 'default' label by .addEventListener("click", handler) to its dynamic .button: ...


3

I thought I would provide you with another approach. It is also a bit hackish, but it is general purpose and allows you to simply register the filename and label that you want to use, like so: if ( class_exists( 'WPSE_196995_Page_Templates' ) ) { WPSE_196995_Page_Templates::register_page_template( 'My Page Template', ...


1

Got around with a ugly hack :-/. I will update the answer If I go with jQuery later on. The solution still requires to have template files but code for the template file loads from the index.php I made a new template/ directory and put all page template there. All page templates are blank. We need it only for them to show up on the dropdown. Use ...


1

It seems that the OP have managed to solve his/her problem by doing this, which can be found at Different menus for logged-in users. if ( is_user_logged_in() ) { wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) ); } else { wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) ); } The more shorter way to achieve that is by ...


1

You can use the WordPress function is_user_logged_in() to check that, and create some basic if statements to show and hide the appropriate code.


1

The best way to customize a navigation menu is to use a custom 'walker' function.. Here are the steps how to achieve the customization that you want! Create a "wp-custom-nav-walker.php" file in your theme directory for a new custom 'walker' class. Extend the Walker_Nav_Menu class and copy the class' function that you want to modify and override it in the ...


0

I think this should work. function upload_image_from_url($url) { /** Require dependencies */ require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); // Save as a temporary file $tmp = download_url( $url ); // ...


1

Try this code <?php //list terms in a given taxonomy $taxonomy = 'industry'; $tax_terms = get_terms($taxonomy); ?> <ul> <?php foreach ($tax_terms as $tax_term) { echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . ...


1

There's an array option when creating a custom post type and custom taxonomy for ""rewrite"" and you can set a ""slug"" and it's there that you can change your permalink structure. For more read here. Also the other option that I get from post 1 and post 2 one helped me blink some idea. 1 Rewrite rule: You need to add a new rewrite rule so Wordpress knows ...


3

The sweet and short of it all is, never try to translate HTML tags. Use placeholders and either printf or sprintf to translate strings with HTML tags Something like this will do printf() printf( __( 'This %s text %s have an %s HTML %s tag. Another sentence...' ), '<em>', '</em>', '<b>', '</b>' ); sprintf() sprintf( __( 'This %s ...


3

The second option will not only (as @mmm already said) confuse translators, but also the order of words in a sentence can be significantly different from one language to another. With the first option a translator can adjust and translate properly, which is not possible with the second one.


0

Please try replacing print apply_filters( 'taxonomy-images-queried-term-image', '' ); with print apply_filters( 'taxonomy-images-list-the-terms', '' ); For WordPress default post type, I created category.php template and altered your code as below. It is showing category image. You can view the snippet here


0

You can use get_object_taxonomies() as your solution. Returns all the taxonomies for a post type or post object: <?php get_object_taxonomies( $object, $output ); ?> Have you tried anything? something like this? // taxonomy term archives $post_type = get_post_type(); // find out if CPT $taxonomies = get_object_taxonomies($post_type); // Find ...


0

By default get_post_meta() returns an array. Set the last parameter to true to return the value of the meta data. See the codex as a reference > Your code should be: $font_awesome_icon = get_post_meta(get_the_ID(), 'font-awesome-icon', true);


0

As you can see here, that font awesome class has many values stored in an array. To use the font-awesome-icon you have to show the array, which is why your code $font_awesome_icon = get_post_meta(get_the_ID(), 'font-awesome-icon',array('size' => 'whatever')); works fine even if there is no value. I would suggest you provide the appropriate "fa" in ...


0

Try this where you need to get the url of the header image and you have set the default: $url = has_header_image() ? get_header_image() : get_theme_support( 'custom-header', 'default-image' );


0

Use shortcode: [theme-my-login show_title=0] or function: <?php theme_my_login( array( 'default_action' => 'login', 'show_title' => '0') ); ?>


1

Do not use any action in form. If you keep empty action of form then data will submit on same page if(isset($_POST["name"])) { echo $_POST["name"]; } <form action="" method="POST"> <input type="text" name="names" id="names"> <input type="submit" value="submit" name="submit_btn"> </form>


1

All thanks to @PieterGoosen's comment, I figured out that this issue was due to a setting within the WPML (multilingual) plugin. Under the 'translation management'->'multilingual content setup' tab of the plugin settings, there is a section for 'custom posts'. In this section, my 'publications' post type was not set for translation, and this somehow ...



Top 50 recent answers are included