Tag Info

New answers tagged

-1

php file add the following code snippet <?php get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_title( '<h1>', '</h1>' ); ?> <?php the_content(); ?> <?php endwhile; // end of the loop. ?> <?php $post = array( 'post_type' => 'post', 'order' => ...


0

This question is pretty broad, so my answer is as well. Set up a new page template. Create a new page, provide some content and a post thumbnail if you like, and use the new page template. In the template itself, first handle the page data, and then set up a custom query. Loop through the posts and clean up. That's basically it. // ... <h1><?php ...


0

This is how I'm calling a taxonomy template from a subdirectory within my theme folder. Keep in mind that taxonomy.php will need to stay in your root theme directory. function call_taxonomy_template_from_directory(){ global $post; $taxonomy_slug = get_query_var('taxonomy'); load_template(get_template_directory() . ...


0

By default WordPress adds lots of CSS classes in body tag automatically. These body classes are very useful for styling different sections/pages of site without needing to edit theme files unnecessarily. For example WordPress add home CSS class on website front page and blog class on blog posts index page. Similarly in your case, since you are using a ...


0

The following will show the current template file to logged in admins only. If you add to the top of your functions file, you should see this info as the first line. add_action('wp_head', 'show_template'); function show_template() { global $template; global $current_user; get_currentuserinfo(); if ($current_user->user_level == 10 ) ...


2

Basic how and why Extending on my blog post about that topic: When you enter a password into a form built by get_the_password_form(), the form targets ~/wp-login.php with a query argument named postpass which is the $action the login file uses to switch. There the PasswordHash class gets into use and a cookie gets set [...] When does it happen? The ...


0

Try reversing the condition : if(post_password_required( )): echo get_the_password_form(); else: // if password not required or password cookie is present // your protected content here endif; See codex Hope that helps.


0

I'd recommend Custom Post Types : http://codex.wordpress.org/Post_Types#Custom_Post_Types You can add appropriate meta boxes to each post type : http://codex.wordpress.org/Function_Reference/add_meta_box You can define specific front end templates for each post type : http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates Instead of a dropdown, ...


2

To be honest, there is no correct or wrong answer here. I do believe that templates are theme territory, although custom post types and taxonomies belongs in a plugin The reasoning behind this is HTML mark up across the theme should be uniform. For instance, if you have templates in a plugin, and you have customized it for the current theme, it will most ...


0

My bad. Should have added a foreach for the replies as well. <?php $args = array( 'user_id' => $curauth->ID, 'number' => 5, 'status' => 'approve', 'parent' => 0 ); $comments = get_comments($args); if ( $comments ) { foreach($comments as $c){ echo '<ul ...


0

Please Provide Proper path to enqueue scripts and styles Example- function theme_name_scripts() { wp_enqueue_style( 'style-name', get_stylesheet_uri() ); wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); then it will work fine


1

If you need to change the template used, you can use the template_include filter (change "itermediate-template.php" and "page.php" with correct file names of your template files): add_filter( 'template_include', 'cyb_exclude_template_for_editors', 99 ); function cyb_exclude_template_for_editors( $template ) { $user = wp_get_current_user(); if( ...


0

Best practice is to use a child theme instead. A plugin like Simple Custom CSS is another option. Two alternate quick fixes: Disable the filter that selects style.min.css by commenting out this line in origin/library/function/styles.php: add_filter( 'stylesheet_uri', 'hybrid_min_stylesheet_uri', 10, 2 ); Delete style.min.css :) There is no ...


0

If you're trying to show content beneath admin bar (and I am assuming this is the reason you wanna get rid of admin bar). Have you consider pushing your page down 32px, since body tag has logged-in class that you can use this code to push content down and keep admin bar: body.logged-in: margin-top:32px;


0

Add This to your function.php it hide the admin bar from frontEnd add_action('after_setup_theme', 'remove_admin_bar_user'); function remove_admin_bar_user() { if (current_user_can('administrator') || is_admin() ) { show_admin_bar(false); } }


1

Templates in general have a strict naming convention according to the Template Hierarchy, regardless of sidebars included or not. Wordpress uses template names according to this hierarchy to decide what template should be dished up for the specific page being viewed. Any template not following this naming conventions set out by the template hierarchy is ...


0

You'll need to add template files to your theme as pr1nc3 linked to. WordPress will automatically load the appropriate file when the taxonomy term is requested.


0

Andrew Bartel is on the right path, but the link doesn't quite do what you want. For static PHP files to access WordPress core functionality you need to add this to the top of the PHP file: define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); (This code is from ...


0

Good question for your first question! Try running the variable through the_contnet Filter - You can use it like this: $editor_value = get_post_meta( $post->ID, "PLUGIN_VALUE", true ); echo apply_filters( 'the_content', htmlspecialchars_decode( $editor_value ) ); I believe what's happening is that whenever you save your postmeta, it is being escaped ...


0

Yes, it is possible. I found this example plugin very helpful. Another approach that is come into my head is using WP Filesystem API to create the template file to theme. I am not sure that it is the best approach to take, but I am sure it work!


1

A hierarchical custom taxonomy works is the same exact way as would the build-in taxonomy category. On the other hand, non hierarchical taxonomies would work exactly like the build-in taxonomy post_tag You have to add terms to your taxonomy in the same way as you would add "categories" in the category screen back end. The template taxonomy-locations.php ...


0

If you don't see template content after create new taxonomy or cpt maybe you could try to refresh your permalinks settings. Wordpress need to crawl for all new items in your system and create new (ie: portfolio, location) url slugs for templates.


0

@PieterGoosen gave some good advice. Focus on that, But if you really wan it, then you can set debug ON temporarily on your website this way. In your wp-config.php use this instead. if ( isset( $_GET['debug'] ) && 'debug' == $_GET['debug'] ) { define( 'WP_DEBUG', true ); } Then access your website homepage/any page and add ?debug=debug at the ...


2

Technically speaking all you need is the Theme Name in your stylesheet header. This will identify your theme. All the other info is need-to-know info and can be omitted. If your theme is a child theme, you will need to have Template as well as this will be the path to the parent theme.


0

Your theme doesn't necessarily include all these template files. It might just use index.php to serve the single page template as well as listings (category, date, author, tag, etc). The articles Theme Development and Template Hierarchy from the codex should get you on the right road with theme development. If you add a single.php file, WP will use that ...


0

step 1: Create or copy content-single.php and create a new file. eg: content-yourCategory.php step 2: Open single.php and replace this get_template_part('content','single'); by the following code if(is_category('yourCategory')){ get_template_part('content','yourCategory'); }else{ get_template_part('content','single.php'); } The ...


0

You can create a custom post type called blog. This would group all your "blog" posts together. Once you have that done, create a template file called archive-blog.php, this will be the file that you can use to list all your posts under the "blog" custom post type. For a single post view, the template would be single-blog.php. These files would reside under ...


1

So long as a plugin / theme doesn't use the dreaded !important rule in their CSS files, you should be quite alright to include your own CSS, and over-ride their settings. However some very badly written plugins / themes do use the !important rule, which unfortunately makes it difficult or even impossible to over-ride their styling. In situations like this, ...


0

Write a function which uses wp_enqueue_style() to enqueue your stylesheet. Then hook your function to wp_enqueue_scripts using add_action(), making sure to use a priority (third argument) that is higher than the priority used by the plugin to enqueue its stylesheet. Refs: http://codex.wordpress.org/Function_Reference/wp_enqueue_style ...


2

From my comment to the OP My opinion, use what you are comfortable with. If there are any performance difference it will be minute/irrelevant. My preference, use the filter To come to your real concern/question, in my opinion, the best approach will be to use the parent category ID and work from there. It will be the least resource intensive to work ...


0

I am updated the answer, so that it will be helpfull to others as well. (For IE, IIRC it's 512 bytes) Helpful links: http://stackoverflow.com/questions/11121286/404-page-not-showing-up-in-ie9#answer-11133855 http://stackoverflow.com/questions/3970093/include-after-php-404-header-returning-oops-this-link-appears-to-be-broken


0

Here is the code I'm using: <?php global $custom_mb; // instead of using helper functions, you can also use ... $sch = get_post_meta(get_the_ID(), $custom_mb->get_the_id(), TRUE); foreach ($sch['docs'] as $img) { echo $img['imgurl']; } ?> Almost worked fine.


1

You could try the loop_start hook depending on what position you want the image and use the code in your functions file. add_action('loop_start', function() { if(is_page(10)) { echo do_shortcode('[plugin_shortcode 1 .....]'); } else if (is_page(11)) { echo do_shortcode('[plugin_shortcode 2 .....]'); } else if (is_page(15)) { echo ...


0

This turned out to be far easier than I had feared, using the portfolio_page_template filter - /** * Override the standard WordPress template with the 'please login' template if the current user is not logged in */ add_filter('template_include', 'portfolio_page_template', 99); function portfolio_page_template($template){ /** List the pages that are ...


0

Place this code snippet put in function.php, this should give you what you need. function my_theme_wp_title( $title, $sep ) { global $post; /* my other title cases */ //get post's modified date $m_date = get_the_modified_date(); //concatenate the current title with the date string, using the separator to be more clear $title .= ...


-1

Kindly refer below : <?php if (get_the_modified_time() != get_the_time()) : ?> <p>Posted: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>, Last Updated: <?php the_modified_time('F j, Y'); ?> at <?php the_modified_time('g:i a'); ?></p> <?php else: ?> <p>Posted: <?php ...


2

As the codex page of get_template_part() says: get_template_part doesn't return a value and doesn't warn if it fails to find a matching template file. Additionally: If you want to hear about failures, use: <?php assert( "locate_template( array('$name-$slug.php', '$name.php'), true, false )" ); ?> So no wonder you are get nothing back. ...



Top 50 recent answers are included