New answers tagged

0

My answer to this is not to continue down this path. It is a good idea to be able to choose a template from the customizer, however, this code looks like it is attempting to save all page data as options and theme mods, and that is a bad idea. Theme Mods are a single option row in the database, and specific to ONLY the theme you are using. Therefore, any ...


0

Figured it out after thinking it through.. if (stripos(strtolower($template_filename), 'home') !== false) { $results[] = $template_name; }


2

You can not replace the URL in the database using ctrl+f or any other "direct" method. You have to do a search & replace in the whole database in a way capable of keeping the validity of serialized data. There are several tools to do that serialized seach & replace. For example: Plugins like Better Search Replace, Velvet Blues Update URLs or ...


0

All settings are stored under child theme domain, so no worries. Just make sure you maintain the same parent theme folder name after updates. You could always backup the old one by renaming its folder.


-2

You don't have any posts query running probably. Try this (added query_posts();) <?php get_header(); ?> <div class="left"> <?php query_posts( $args ); if ( have_posts() ) : // Start the loop. while ( have_posts() ) : the_post(); //echo for debugging echo 'index<br>'; echo ...


5

Say if your have header-video.php used for video post format. Replace get_header(); with get_header(get_post_format()); in your regular singular.php or index.php. If WP can find header-video.php it will load it otherwise it will automatically will fallback to header.php.


1

You can put in different headers and call them depending on your different post formats. So, as well as as header.php you might add: header-awesomevid.php. Then within your templates you can call the custom headers, eg: if ( has_post_format( 'video' )) { get_header ( "awesomevid" ); } else { get another exciting header } else { use default header }


3

The use of function_exists is a very bad habit that should simply be avoided in favor of using actions and filters. If you want child themes to be able to override some functionality you need to be very specific about which one and how, and function_exists is usually not specific enough for that.


0

if customizer(live preview) doesnt work or doesnt load and nothing is shown, try these steps: do you have redirections on the problematic site (double check and ensure, there might be coded a custom redirection in your plugins/codes)? while the circle is still loading, change any option in customizer and click "SAVE & PUBLISH" and see, maybe a simple ...


0

You might try changing the class login to an id login. Replace .login h1 a {...} with #login h1 a {...}.


0

Other WordPress starter-themes that include Bootstrap: https://github.com/SimonPadbury/bst


1

Well it turns out Apple News doesn't accept password-protected RSS feeds. Thanks for the help!


0

Jevuska is answer is corrected below detail of code check user role current user and display content conditionally. if ( is_user_logged_in() ){ $current_user = wp_get_current_user(); $roles = $current_user->roles; $level = 0; foreach( $roles as $role ){ if( in_array( array( 'administrator', 'shop-manager', 'adoption-agency'), ...


1

Your problem is that current_user_can() takes a capability not a user role. So, to check for an administrator, for example, you might use: if ( current_user_can( 'manage_options' ) ) { ... } because ordinarily only admins can manage options. You'd have to tie your custom user roles to capabilities that correspond to their roles, which are defined for ...


1

This is a shot in the dark because I can't see the site... Check the way your theme uses css to align your sidebar and see if the width that is being set to the div by the user is causing the post container to become too wide, pushing the sidebar down. You could use some css to control elements within the posts container such as: I would try to find the ...


1

I would consider this not really a typical WP question – maybe you should ask over at http://unix.stackexchange.com – but maybe this could already help anyways: If you have access to the server config and you know the IP address of FB Instant Articles and Apple News you could for example block everybody from accessing your feed – but allow FB Instant ...


0

You're looking for: underscore S (_S) theme, maintained by WordPress theme itself. Here is the link: http://underscores.me/ Another good one to start is: https://wordpress.org/themes/clean-simple-white/


0

Already fixed it. When saving it to the database the hashtag is filtered out. So with echoing the color, I just put a hashtag before it, like this: function cloudboxx_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->add_setting( 'header_textcolor' , array( 'default' ...


3

Sidebars are stored in global variable $wp_registered_sidebars. You can get the sidebar properties using this variable. global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars['sidebar-2'] ) ) { echo $wp_registered_sidebars['sidebar-2']['name']; } Note that do not use it too early, either on/after widgets_init hook or in a template ...


0

Swopnil Dangol is correct, However seeing that you are editing a standard wordpress theme in the first place with bootstrap i would not bother the below answer is the for lazy man. php echo get_template_directory_uri(); ?> infront of the urls


0

If you want to link stylesheets and scripts in wordpress,the correct way is to use wp_enqueue_style() and wp_enqueue_scripts() in your functions.php file Try this in your functions.php file wp_enqueue_style('bootstrap-css',get_template_directory_uri().'/bootstrap/css/bootstrap.min.css'); ...


0

Add the menu_class argument with value of cd-accordion-menu to your code, so that it looks like this: <div class="menu-container"> <nav id="site-navigation" class="main-navigation" role="navigation"> <?php wp_nav_menu(array( 'theme_location' => 'primary', 'sort_column' => 'menu_order', 'menu' => ...


0

Add !important; to EVERYTHING and that should solve your problem. You don't have your first 4 background items as !important; so they are being overridden. This is why it doesn't work anymore.


-1

You can use Menu Swapper plugin for doing same thing from admin panel. Here is the Demo of this plugin.


0

You don't generate a WP Loop using wp_get_recent_posts() so get_the_time() won't pull the post date. The post date is available within the array wp_get_recent_posts() returns though: $recent['post_date']. Or you can use the modified date: $recent['post_modified']. This works (tested on my dev site): <?php $args = array( 'post_status' => ...


1

I think you need to do something like this: <?php $args = array( 'post_type' => 'shop', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'cu_status', 'value' => array( ...


0

So after a long search I found my mistake. In the functions.php wp_enqueue_scripts( 'awesome-landing-page' ); Should bewp_enqueue_script( 'awesome-landing-page' ); Without the 's'. Seems like a beginners mistake, so sorry for bothering. Still I find the misbehaviour of the Apache misleading. Bye for now!


0

I think You have error on default value for setting, You write 'default' => 'fa-fa box' instead 'fa fa-box'. I can't find box icon on fontAwesome too.


0

You can do that by by editing the template-tags.php in the inc directory. Find: sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time ) Replace: sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $regular_time ) Find: sprintf( '<a class="entry-date" ...


0

the_post_thumbnail() can only be used in "the Loop". What you need is get_the_post_thumbnail(). (See details and code examples on the code reference page). So something like: foreach( $recent_posts as $recent ){ echo '<li>'; echo get_the_post_thumbnail( $recent['ID'], 'size', array( 'class' => 'alignleft' ) ); echo '<a href="' . ...


0

When developing a theme, you should turn on WP_DEBUG in wp-config.php. It will tell you what the error is. For your case, it seems a syntax problem which leads to server down, not an apache issue.


-1

You have to use post meta for this. (The post meta data is, information you provide to viewers about each post.)


6

I work with several large WordPress sites, news sites specifically, that have thousands of posts and thousands of visitors (300k/day). With the stuff below, and a well coded theme, with well written queries, we're loading in 2.5s with 7 ad blocks from AdSense and RevContent. Do you have a CDN? I highly recommend a CDN if you don't have one. Depending on ...


1

I think you have the logo called from the Theme Options try updating your Theme Options alternatively you have many plugins that can help you achieve that. Like: https://wordpress.org/plugins/add-logo-to-admin/ You can always refer to the Wordpress Codes https://codex.wordpress.org/Customizing_the_Login_Form


1

Off the top of my head I can't think of any instance where you would want the WordPress admin to be the main entry point for your website, that there isn't a more suitable software to use. Do you have a specific application or use in mind? In general I would say say, yes it is best practice to keep the admin potion of your WordPress install for ...


1

@AlexanderFarber, there are many way to attach attribute class under wp_nav_menu link. I agree with @Sumit, adding page links in Appearance > Menu WordPress take care of current-menu-item class or current_page_item class. Also, this way is best practice to handle your nav menu in the future. Create dynamic link in wp_nav_menu Since your question related ...


0

Here is my own solution - in the /wp-content/themes/twentythirteen-child/functions.php file add the current-menu-item CSS style if the page slug is player: function my_nav_menu_items( $items ) { $profile = sprintf('<li class="menu-item menu-item-type-custom menu-item-object-custom %s"><a ...


1

You can add any value you want to the "Tags" header. You are limited only if you want your theme be listed in some web. In that case, you must follow the restrictions that the owner/community of that web has set. For example, if you want your theme be listed in WordPress.org themes directory, you must follow the requirements published by the Theme Review ...


0

The other pages show a 'current menu item' css state: .nav-menu .current_page_item > a, .nav-menu .current_page_ancestor > a, .nav-menu .current-menu-item > a, .nav-menu .current-menu-ancestor > a { color: #bc360a; font-style: italic; This page is showing as 'page-id-32'. If that corresponds to the page in the menu it should show the ...


1

Your child theme functions.php loads before the parent theme's, so you're trying to remove the action before it's added by the parent theme. Hook after_setup_theme to remove/add, which is executed after both child and parent load. add_action( 'after_setup_theme', 'wpd_wp_head_function' ); function wpd_wp_head_function() { remove_action( 'wp_head', ...


1

To clarify why it happened, it's because rtrim( $text, '[...]' ) notation used to remove the default ellipsis in some themes is incorrect. Per trim() function description, the second argument is treated as a list of characters, not as a string. Moreover, [... is treated as a range of ASCII characters from full stop (code 2E) to opening square bracket (code ...


3

Here you go. Since you already have the menu-id all you need is: $menu_item_defaults = array( 'menu-item-db-id' => $menu_item_db_id, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 1, ...


0

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title( '<h3>', '</h3>' );// puts the title in h3 tags the_content(); // adds the content endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> Notice that you can use the title function where ...


0

Put this lines of code in function.php if (function_exists("register_sidebar")) { register_sidebar(); } Put this to sidebar.php <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <?php $image = new WP_query ('showposts=1'); if(have_posts()) : while($image->have_posts()) : $image->the_post; ?> <a ...


1

By the sounds of it, your custom theme is missing the common hooks that allow plugins to alter/output their code. To take a simple example, every theme should have a call to wp_head() somewhere in the section of the output page. This allows a plugin to "hook" into your , and for example, output code to load its Javascript. Here's a real-life example. The ...


0

The following code only load the content of page template <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content(); // show the content endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?>


0

In my understanding (and I'm not a lawyer, etc etc), this would not count as distribution. I make this distinction mainly based on the fact that a separate GPL-flavoured license actually exists where this would count as distribution - the GNU Affero General Public License. GitHub's choosealicense.com states: GNU AGPLv3 is distinguished from GNU GPLv3 ...


0

One simple way of doing it is by using a php function called "basename". If you have 2 header headerone.php, headertwo.php you can load different resources depending upon the name of the page you are viewing. <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <?php if(basename($_SERVER['PHP_SELF']) == ...


1

I agree with @Zlatev that you probably wouldn't want to do this clientside. There are easier ways to include less. There are plugins that allow you to do this. Even jetpack has less support. If your goal is to include this in your theme you can use wp-less. Just download that plugin and drop in somewhere in your theme and include it in your ...


0

Originally I said You could make your child theme stylesheet import another stylesheet @import url("subdirectory/file.css");* But this was incorrect as this is no longer the preferred way to reference a style sheet. Now, I have discovered a plugin that makes child's play of creating a child theme (please excuse the pun) ...



Top 50 recent answers are included