tokyobear
Forum Replies Created
-
Forum: Plugins
In reply to: [Quiz Maker] Plugin removes HTMLThank you
Forum: Plugins
In reply to: [Search Exclude] Include in Custom QueryThank you for the prompt response. The below is the code that is used on a single.php page in the theme (i.e. within another post). $postarea is defined through a custom field. The filter works as intended. But if I check “Exclude from Search Results” in any one of the posts then it disappears from the results. Thank you in advance for the help.
// define query parameters based on attributes
$options = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => -1,
‘relation’ => ‘AND’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘location’,
‘field’ => ‘slug’,
‘terms’ => $postarea,
‘include_children’ => true,
‘operator’ => ‘IN’,
),
),
);$query = new WP_Query( $options );
// run the loop based on the query
if ( $query->have_posts() ):?>Forum: Everything else WordPress
In reply to: get_tag_link returns all postsUpdated… In the tag.php file I have the following code before my loop…
<?php $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $keys = parse_url($url); // parse the url $path = explode("/", $keys['path']); // splitting the path $last = end($path); // get the value of the last element ?> <?php $args = array( 'post_type' => 'guide', 'tag' => $last, 'orderby'=> 'title', 'order' => 'ASC', 'posts_per_page' => -1 );?>
… which doesn’t work — is there a way I can get the last segment of the URL for this array? (previously I used the GET function when I had the default permalinks and it worked fine)
Forum: Fixing WordPress
In reply to: Grey Banner background ProblemBy custom theme I meant my own theme. I solved the issue by adding the below code:
img {background:transparent !important;}
I can’t see the same in the pre-packaged themes so no doubt there’s a better solution but this one works.
Forum: Fixing WordPress
In reply to: Grey Banner background ProblemIs there a solution to this problem? I’m facing the same issue on a custom theme. If I switch to TwentyEleven or one of the pre-packaged themes my png’s (24) appear transparent but then when I use my own theme they all have a grey background… am I missing some CSS code?
By the way, within my own theme if I click the image so it loads in a separate page the image appears transparent…
Forum: Plugins
In reply to: [Ambrosite Next/Previous Post Link Plus] Adapting for a "View All" pageJust in case anyone else has this same problem, I thought I’d submit my solution. This thread, as pointed to by ambrosite, was a great starting point and may well be the solution for many.
For me it wouldn’t work because I didn’t have a parent category; I had a custom post (‘portfolio’) and then a number of categories/groups (‘landscape’, ‘coastal’, and so on).
Anyway, in functions.php as per the thread above:
function init_sessions() { if (!session_id()) { session_start(); } } add_action('init', 'init_sessions')
In the footer (just above
wp_footer()
):if ($_GET['group']==FALSE) { $_SESSION['history'] = "ViewAll"; } else { $_SESSION['history'] = "Group";} if ($_SESSION['history'] == "Group") { $_SESSION['myVar']="Group";} elseif ($_GET['portfolio']==FALSE) { $_SESSION['myVar']="ViewAll";}
And in my single.php:
if(isset($_SESSION['history'])){ if ($_SESSION['history'] == "Group" || $_SESSION['myVar'] == "Group") { next_post_link_plus(in_same_tax set to TRUE) previous_post_link_plus(in_same_tax set to TRUE) else { next_post_link_plus(in_same_tax set to FALSE) previous_post_link_plus(in_same_tax set to FALSE)} }
The code basically pulls the variable from the previous URL so it knows that you clicked on ‘image1’ by coming through ‘Coastal’ and not ‘View All’. The problem is that this refreshes as you click through the next post — in other words the computer doesn’t know whether you got to ‘image2’ by going… ‘Coastal’ –> ‘Image1’ –> ‘Image2’ OR ‘View All’ –> ‘Image1’ –> ‘Image2’
That’s why I set the MyVar to ‘Group’ as soon as $_SESSION[‘history’] == “Group” (hence the OR statement in single.php).
elseif ($_GET['portfolio']==FALSE) { $_SESSION['myVar']="ViewAll";}
The above code is included so that if the user clicks on another other page (I have links to featured images in the sidebar) then myVar is changed and if the user clicks on ‘image1’ from the sidebar then he will enter the general loop…(URL for single images is ?portfolio=image1)
I guess this solution doesn’t work if you change the permalinks from the default setting in WP (since I’m using $_GET) but it’s one way round the problem so I thought I’d post…
I think this solution also enables you to select more than one category, as well — I haven’t tried but I don’t immediately see an issue.
Forum: Plugins
In reply to: [Ambrosite Next/Previous Post Link Plus] Adapting for a "View All" pageFairly new to all this but I’ll take a shot!
Thanks again for the prompt response!
Forum: Plugins
In reply to: [Ambrosite Next/Previous Post Link Plus] Using PHP in array for image linkI followed your advice using:
bloginfo('template directory')
to echo the function and I realised that I just needed the underscore! =)
get_bloginfo('template_directory')
Thanks!
Forum: Plugins
In reply to: [Ambrosite Next/Previous Post Link Plus] Using PHP in array for image linkThank you for the prompt response!
I’m afraid that didn’t work. Incidentally, I’m testing on a localhost if that makes any difference?? I know the following works in CSS:
background-image: url(../mulberry/images/background-3.png);
And I tried adding the ‘mulberry’ (theme name) into your code:
'<img src="' . get_bloginfo('template directory'). 'mulberry/images/right-arrow.png" />',
But to no avail. I’m sure the issue is my end so I’ll keep on trying…
Thanks.
Forum: Fixing WordPress
In reply to: get_term_link stops rest of website from loadingSolved…
<?php $args = array( 'post_type' => 'portfolio', 'taxonomy' => 'Type', 'term' => $_GET['type'], 'posts_per_page' => 20 );?> <?php $loop = new WP_Query( $args );?>
The above in taxonomy-type.php
And then I take the term from the link…
<a href="<?php echo get_term_link('Landscapes', 'Type');?>">Landscapes</a>
Forum: Fixing WordPress
In reply to: get_term_link stops rest of website from loadingMaking slow progress — will post in the hope that someone can push me over the line (relatively new to WP and PHP…).
I can achieve what I want but is it really the case that for every new category I create in my custom post I have to create a file called..
taxonomy-type-[insert category… landscape/cityscape, etc.].php
…?
If that’s the case, so be it. Otherwise, I’d appreciate someone pointing me in the right direction. Thanks.
Forum: Fixing WordPress
In reply to: get_term_link stops rest of website from loadingUpdate…
If I change
get_term_link('Landscapes','Portfolio');
to
get_term_link('Landscapes','Type');
… then the page loads correctly. But it displays ALL photographs loaded into a portfolio post and not just the ones with the type/category ‘landscapes’…
Feel I’m missing something obvious…
Forum: Fixing WordPress
In reply to: get_term_link stops rest of website from loadingAnd like so for the full code with the get_term_link error:
<li><a href="<?php echo get_settings('home');?>">Blog</a></li> <li><a href="<?php echo get_post_type_archive_link('portfolio');?>">Gallery</a></li> <li><a href="<?php echo get_term_link('Landscapes','Portfolio');?>">Landscapes</a></li> <li><a href="?page_id=13">Guide</a></li>
Forum: Fixing WordPress
In reply to: get_term_link stops rest of website from loadingCode for the menu should read:
<li><a href="<?php echo get_settings('home');?>">Blog</a></li> <li><a href="<?php echo get_post_type_archive_link('portfolio');?>">Gallery</a></li> <li><a href="?page_id=13">Guide</a></li>