Tag Info

New answers tagged

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 ...


1

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. ...


0

Simplest way is to use single_template filter hook (one of the {$type}_template hooks). It is fired by WordPress to filter the template file found for singular post requests. add_filter('single_template', function($template) { $queried = get_queried_object(); if ( $queried->post_type === 'clients_projects' ) { // only for this CPT // file name ...


0

OK. I have found the fix to my problem. Here are the steps: Thanks to Howdy_McGee who found where the problem was (see first answer above) I located the cause of all my pains. Opened the compressed.css file with my cpanel file manager and found the line .column{float:left;margin:0 10px;padding:0;} Then I added the following code ...


0

The widths are the same the problem is that you have this in your compressed.css - Line 55: .column { float: left; margin: 0 10px; padding: 0; } Whenever you float your column left you lose your max-width as it becomes inline. Fix that fix your website. The homepage content, or all the content is in that column class.


-1

Use filter single_template to change template file and function in_category to check is this post in category. add_filter( 'single_template', 'my_single_template' ); function my_single_template($single_template) { if (in_category(1)) { $file = get_template_directory().'/single-cat-1.php'; if ( file_exists($file) ) { return ...


0

You can use this function to add category specific single template pages on your website. This goes in functions.php You can define as many single templates as you want. function wpse_category_single_template( $single_template ) { global $post; $all_cats = get_the_category(); if ( $all_cats[0]->cat_ID == '1' ) { if ( ...


1

I don't know what your definition of "simple" is, so not sure this qualifies. It's not really a simple task to do this dynamically. First, we register a new query var to pass the alternate identifier: function wpd_portfolios_query_var($query_vars){ $query_vars[] = 'portfolio_key'; return $query_vars; } add_filter('query_vars', ...


2

The "cheapest" way to achieve this probably would be to simply add two pages: // Standard template http(s)://example.com/portfolio-xyz Then add another page with your second URl and use a custom page template where you query your single post using get_post() and display it however it pleases you: <?php /* Template Name: Alternate Portfolio PT template ...


0

As said in one of the comments, this is really simple. Within your theme folder, you can create a file called category.php. Once in place, you can modify to your hearts content without the need to do anything fancy such as redirection. If you want to target a specific category, let's say music, then the file would be category-music.php It's also worth ...


1

This is an older post, but maybe this will help somebody. In your archive-my-cpt.php file you can use get_page_by_path( 'my-page-slug' ); to get the page object you're looking for and go from there. In other words, let the default template load up, then run grab the page data for the page you want to display, and spit out that page data in a custom loop. ...


0

You need to hook into the image_send_to_editor filter. This allows you to modify the markup used when inserting an image into the content editor. Something like this should work: add_filter('image_send_to_editor', 'my_add_rel_nofollow', 10, 8); function my_add_rel_nofollow($html, $id, $caption, $title, $align, $url, $size, $alt = '' ){ // check if ...


0

I realize that this was posted about 7 months ago, but in case you're still looking for a solution to this, add this to your functions.php file: /** * Add a shortcode for the current theme directory * @return string Current theme directory */ function yourtheme_get_theme_directory_uri() { return get_template_directory_uri(); } add_shortcode( ...


2

When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The meta_key is _wp_page_template and the meta_value will be the page template You can simply make use of get_pages to retrieve all pages which have a meta_value of the specified template $pages = get_pages(array( 'meta_key' => ...


0

If you want to use one file as a "taxonomy" template, but want to style posts differently by post type, I'd advise using an if statement. I'm not sure how far you're going, but if you're just changing the loop for example, it would look something like this: Using this question as reference. <?php while ( have_posts() ) : the_post(); if( ...


1

This is how its done in Twenty Fourteen which uses a template tag: Note: The conditionals if ( is_sticky() && is_home() && ! is_paged() ) { will need to be changed or removed if ( ! function_exists( 'twentyfourteen_posted_on' ) ) : /** * Print HTML with meta information for the current post-date/time and author. * * @since Twenty ...


0

So @Sharma, The file you are looking for is the archive.php, but if you cannot change the things you want is because the archive.php is including another file for that. A good way to check Template files and how the behave, is the Codex Page about Template Hierarchy. If you don't find what you are looking for on your archive.php please post it's ...



Top 50 recent answers are included